Compile Error when calling a sub function

primonoy

New Member
Joined
Sep 23, 2014
Messages
2
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

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!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Welcome to the forum. :)

If you don't use Call, you don't use the brackets:
Code:
FormatList 2, ">>Header Title<<"
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,583
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top