I'm struggling to figure out how to colour cells based on a string in the cell
my excel data looks like this
I will have problems with the 0s and planned on dealing with it later or removing it from the data output source
Name
1.01 - words
1.02 - words
1.03 - words
1.04 - words
and sometimes like this
1-1 - words
1-2 - words
1-3 - words
1-4 - words
Thanks for the help
my excel data looks like this
I will have problems with the 0s and planned on dealing with it later or removing it from the data output source
Name
1.01 - words
1.02 - words
1.03 - words
1.04 - words
and sometimes like this
1-1 - words
1-2 - words
1-3 - words
1-4 - words
VBA Code:
Sub ColourHeaders()
'
' ColourHeader Macro
'
' Keyboard Shortcut: Ctrl+k
'
Dim sReturn As String
sReturn = InputBox("Enter Item section number ex.1 for section with numbers of 1-1,1-2... : ")
Dim sReturn1 As String
sReturn1 = InputBox("Specify . or - for deliniation")
Dim sReturn2 As String
sReturn2 = InputBox("0 before singles numbers ex. 01 enter yes or no")
Dim count As String
Dim counter As Integer
counter = ActiveCell.Row
Dim counter2 As Integer
counter2 = 1
Dim x As Range
Set x = Range(ActiveCell, ActiveCell.Offset(0, 0))
Dim y As Range
Set y = Range(ActiveCell, ActiveCell.Offset(0, 0))
Do While x.Offset(counter, 0).Value <> ""
If sReturn2 <> "no" Then
count = "0" & CStr(counter2)
End If
If sReturn2 <> "yes" Then
count = CStr(counter2)
End If
If InStr(1, CStr(y.Offset(counter - 1, 0).Value), sReturn & sReturn1 & count) <> 0 Then
y.Offset(counter - 1, 0).Resize(1, 11).Interior.Color = RGB(165, 165, 165)
counter2 = counter2 + 1
End If
counter = counter + 1
Loop
MsgBox y.Offset(counter - 1, 0).Value
MsgBox count
MsgBox counter
MsgBox counter2
MsgBox sReturn & sReturn1 & count
End Sub
Thanks for the help