VBA not recognizing variable value in excel

I have a process that needs to dynamicallty determine the ending column for a range of data.  The strColumnLetter in debug print does return "F".  But the code simply does not  recognize it.
Public Function DataSourceRatings(strWbkDestination As String, strWbkSource As String) As Boolean 'Actually passing the TEST_Client workbook name here.
'*****************************************************************************
' Copies the RATING worksheet data to the DataSource
' worksheet which is where the Client worksheets will drawn their
' rating data in a query rather than linking to the ActiveMasterWorkoook.
'*****************************************************************************
On Error GoTo ErrorHandler
Dim intLastColNum As Integer
Dim intColNum   As Integer
Dim strLastColumn As String
Dim strColumnLetter As String

With Workbooks(strWbkDestination) 'Current month's Green Package destination workbook
    .Activate
        With .Worksheets("DataSource")
                .Activate
                .Range("A1").Activate
                .Range("A1") = "RATING - AM WORKING ON IT - DO NOT INTERRUPT!"
                .Range("B1") = "ClientRatingsDetail"
        End With
End With

        If Not QueryWorkSheet(strWbkDestination, strWbkSource, "RAT", "A", "ds_RAT") Then
            DataSourceRatings = False
        Exit Function
        End If
        
'Determine last column number and letter
strLastColumn = Range("IV3").End(xlToLeft).Address
Debug.Print "Last Column: " & strLastColumn

intColNum = Range(strLastColumn).Column
Debug.Print "Col Number: " & intColNum

 strColumnLetter = fntColNo2ColRef(intColNum)
 Debug.Print "Column Letter: " & strColumnLetter
 
With Workbooks(strWbkDestination) 'Current month's Green Package destination workbook
    .Activate
'Title columns, reformatting and coloring fields
    With Worksheets("DataSource")
        .Columns("A:" & strColumnLetter).ColumnWidth = 20
        .Range("A1:" & strColumnLetter & "3").WrapText = True
        .Range("A1:" & strColumnLetter & "3").Font.Bold = True
        .Range("A1:" & strColumnLetter & "3").WrapText = True
        .Range("A1:" & strColumnLetter & "3").Interior.Color = RGB(198, 226, 255)
        .Range("A2").Value = 1
        .Range("A2:" & strColumnLetter & "2").DataSeries Rowcol:=xlRows, Type:=xlLinear, _
                        Date:=xlDay, Step:=1, Trend:=False
    End With
End With
        
 'Check to see which type and then delete rows accordingly    Call DeleteCertainBlankRows(strWbkDestination, "A", "B", strColumnLetter)
    Call CreateDatSourceRangeNames(strWbkDestination, "A", strColumnLetter, "RAT")
       

'Format column B for proper aligment after all copy/pastes have been completed
With Workbooks(strWbkDestination).Worksheets("DataSource")
    .Activate
        Columns("B:B").Select
            With Selection
                .HorizontalAlignment = xlLeft
                .Orientation = 0
                .AddIndent = False
                .IndentLevel = 0
            End With
End With
    
With Workbooks(strWbkDestination) 'Current month's Green Package destination workbook
.Activate
    With .Worksheets("DataSource")
            .Activate
            .Range("A1") = "RATING "
    End With
End With
    
    DataSourceRatings = True
    
Exit_ErrorHandler:
    Exit Function
ErrorHandler:
    If Err.Number = 9 Then
        MsgBox "Error Number: " & Err.Number & vbCrLf & vbCrLf & "Description: " & _
            "The file " & strWbkDestination & "  does not exist or is not open.", vbOKOnly
            DataSourceRatings = False
            Resume Exit_ErrorHandler
    Else
        MsgBox " Error Number: " & Err.Number & vbCrLf & vbCrLf & "Description: " & Err.Description & _
                vbCrLf & vbCrLf & " Procedure: DataSourceRatings", vbOKOnly
        DataSourceRatings = False
        Resume Exit_ErrorHandler
    End If
End Function

Open in new window

Sandra SmithRetiredAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zorvek (Kevin Jones)ConsultantCommented:
Which line fails?

Kevin
0
zorvek (Kevin Jones)ConsultantCommented:
Try this change. Change:

'Determine last column number and letter
strLastColumn = Range("IV3").End(xlToLeft).Address
Debug.Print "Last Column: " & strLastColumn

intColNum = Range(strLastColumn).Column
Debug.Print "Col Number: " & intColNum

 strColumnLetter = fntColNo2ColRef(intColNum)
 Debug.Print "Column Letter: " & strColumnLetter
 
With Workbooks(strWbkDestination) 'Current month's Green Package destination workbook
    .Activate
'Title columns, reformatting and coloring fields
    With Worksheets("DataSource")
        .Columns("A:" & strColumnLetter).ColumnWidth = 20
        .Range("A1:" & strColumnLetter & "3").WrapText = True
        .Range("A1:" & strColumnLetter & "3").Font.Bold = True
        .Range("A1:" & strColumnLetter & "3").WrapText = True
        .Range("A1:" & strColumnLetter & "3").Interior.Color = RGB(198, 226, 255)
        .Range("A2").Value = 1
        .Range("A2:" & strColumnLetter & "2").DataSeries Rowcol:=xlRows, Type:=xlLinear, _
                        Date:=xlDay, Step:=1, Trend:=False
    End With
End With

To:

'Determine last column number and letter
intColNum = Range("IV3").End(xlToLeft).Column
 
With Workbooks(strWbkDestination) 'Current month's Green Package destination workbook
    .Activate
    'Title columns, reformatting and coloring fields
    With Worksheets("DataSource")
        .Range("A2").Value = 1
        With .Range("A1").Resize(1, intColNum)
            .EntireColumn.ColumnWidth = 20
            With .Resize(3)
                .WrapText = True
                .Font.Bold = True
                .WrapText = True
                .Interior.Color = RGB(198, 226, 255)
            End With
            .Offset(1).DataSeries Rowcol:=xlRows, Type:=xlLinear, Date:=xlDay, Step:=1, Trend:=False
        End With
    End With
End With

Kevin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sandra SmithRetiredAuthor Commented:
Let me try your suggestions.  I am simply going around and around.

Sandra
0
Sandra SmithRetiredAuthor Commented:
Worked, thank you.  This project has been changed to four month's worth of work in thee weeks so more questions will be coming your way!

Sandra
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.