Hi guys,
I'm new in this forum and a noob in excel VBA. I have some issues with sub functions.
I created a sub function that I can call inside another sub function but it returns a "Complie Error: Expected: ="
My goal is to format cells with the number of "*"
here is how i call the sub function:
FormatList (2,">>Header Title<<")
Below is my code
I hope someone can help me
Thanks!
I'm new in this forum and a noob in excel VBA. I have some issues with sub functions.
I created a sub function that I can call inside another sub function but it returns a "Complie Error: Expected: ="
My goal is to format cells with the number of "*"
here is how i call the sub function:
FormatList (2,">>Header Title<<")
Below is my code
Code:
Sub FormatList(iHeaderRow As Integer, sHeaderTarget As String)
sSheetCurrent = ActiveSheet.Name
'Find Headers
For IFind = 1 To 100
If Worksheets(sSheetCurrent).Cells(iHeaderRow, IFind) = sHeaderTarget Then
iHeaderYCol = IFind
End If
Next
'Find End
For IFind = 1 To 10000
If Worksheets(sSheetCurrent).Cells(IFind, iHeaderYCol) = ">>END<<" Then
iEndXRow = IFind - 1
End If
Next
Select Case sHeaderTarget
Case Is = "*Basic Product Details*"
sLvl1Color = "vbBlack"
sLvl1Size = 12
sLvl2Color = "-16777024"
sLvl2Size = 12
sLvl3Color = "vbBlue"
sLvl3Size = 11
Case Is = "*Product Feature*"
sLvl1Color = "vbBlack"
sLvl1Size = 13
sLvl2Color = "-16777024"
sLvl2Size = 12
sLvl3Color = "vbBlack"
sLvl3Size = 12
sLvl4Color = "vbBlue"
sLvl4Size = 11
sLvl5Color = "-3407668"
sLvl5Size = 10
End Select
For IFind = iHeaderRow To iEndXRow
sTmpItem = Worksheets(sSheetCurrent).Cells(IFind, iHeaderYCol)
iLenTmpItem = Len(sTmpItem) - Len(Replace(sTmpItem, "*", "")) - 1
If iLenTmpItem = 1 Then
Worksheets(sSheetCurrent).Cells(IFind, iHeaderYCol).Select
With Selection.Font
.Color = sLvl1Color
.TintAndShade = 0
.Bold = True
.Size = sLvl1Size
End With
End If
If iLenTmpItem = 2 Then
Worksheets(sSheetCurrent).Cells(IFind, iHeaderYCol).Select
With Selection.Font
.Color = -16777024
.TintAndShade = 0
.Bold = True
.Size = sLvl2Size
End With
End If
If iLenTmpItem = 3 Then
With Selection.Font
.Color = sLvl3Color
.TintAndShade = 0
.Bold = True
.Size = sLvl3Size
End With
End If
If iLenTmpItem = 4 Then
With Selection.Font
.Color = sLvl4Color
.TintAndShade = 0
.Bold = True
.Size = sLvl4Size
End With
End If
If iLenTmpItem = 5 Then
With Selection.Font
.Color = sLvl5Color
.TintAndShade = 0
.Bold = True
.Size = sLvl5Size
End With
End If
Next
End Sub
I hope someone can help me
Thanks!