Eloise T
Active Member
I need a VBA to start in Row 3 and go down column G and change any date from whatever format it may be to mm/dd/yyyy ...until it reaches a blank cell.
I will be adding it to this which already contains 3 modules (ChanageCase, TRIMnCLEAN, and REDnBOLD) which act on other columns:
Thank you in advance.
I will be adding it to this which already contains 3 modules (ChanageCase, TRIMnCLEAN, and REDnBOLD) which act on other columns:
Code:
Sub ChangeCase()
' ChangeCase is three VBA modules in one. See ChangeCase(), TRIMnCLEAN(), and REDnBOLD() below.
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Formula Info" Then
'If ws.Name <> "Formula Info" And ws.Name <>"Tech Rate" Then Note: to add more just put (And ws.Name <> "name") before Then
' Change "Formula Info" sheet name or you can use sheet index# instead of name.
If ws.Cells(Rows.Count, 5).End(xlUp).Row > 2 Then
' This line was added to "fix" Error 400 which was caused by blank tab(s).
' The "Next Tech" tab has no data, and its header is in row 2.
' The part which returns the last row of data is: ws.Cells(Rows.Count, 5).End(xlUp).Row
' which will return 3 or more as long as the worksheet has data; thus subtracting 2 from
' this value returns any number from 1 upwards. However, when the worksheet has no data,
' the above code will return 2, and subtracting 2 from this = 0, which is an invalid row
' number in Excel. To check this, we test whether the value returned by the above code
' is greater than 2; if so, we proceed further, else we exit.
' The 5 in (Rows.Count, 5) tells it to start in the 5th row.
'----------------------------------------
' Sub ChangeCase()
With ws.[E3:F3].Resize(ws.Cells(Rows.Count, 5).End(xlUp).Row - 2)
' > > > This VBA changes all characters in the array defined by Columns E and F to UPPER case.
' E3:F3 array tells where to apply change(s). (Rows.Count, 5) tells in which column to start.
.Value = .Parent.Evaluate(Replace("IF(#>"""",UPPER(#),"""")", "#", .Address))
End With
'----------------------------------------
' Sub TRIMnCLEAN()
With ws.[A3:D3].Resize(ws.Cells(Rows.Count, 5).End(xlUp).Row - 2)
' > > > This VBA removes leading and trailing spaces in the array of Columns A through F.
' A3:D3 array tells where to apply change(s). (Rows.Count, 5) tells in which column to start.
' .Value = .Parent.Evaluate(Replace("IF(#>"""",TRIM(#),"""")", "#", .Address)) yields only removing leading and trailing spaces.
' Added CLEAN to remove leading and trailing ASCII characters 0-31.
.Value = .Parent.Evaluate(Replace("IF(#>"""",TRIM(CLEAN(#)),"""")", "#", .Address))
End With
'----------------------------------------
' Sub REDnBOLD()
For Each cll In ws.Range(ws.Cells(3, "C"), ws.Cells(ws.Rows.Count, "C").End(xlUp)).Cells
' > > > This VBA segment changes the TV Model screen size between 70 and 90 inches to red and Bold and
' starts in Row 3, Column C, and applies to each tab in the Excel workbook, except for tab "Formula Info" tab.
With cll
x = Evaluate("MIN(IFERROR(FIND(ROW(10:99)," & .Address(0, 0, , 1) & "),""""))")
If x > 0 Then
y = CLng(Mid(cll.Value, x, 2))
If y >= 70 And y <= 90 Then
With .Characters(Start:=x, Length:=2).Font
.FontStyle = "Bold"
.Color = -16776961
End With
End If
End If
End With
Next cll
' End Sub
'----------------------------------------
End If
End If
Next
End Sub
Thank you in advance.