Need Help Again :( Sending values to a Function

agustinodavalos

New Member
Joined
Aug 17, 2015
Messages
3
Sub Worksheet_Change(ByVal Target As Range)
intColumnData = HCCRange()
StrClmData = CNumToLetter(intColumnData)
End Sub

Function CNumToLetter(iCol As Integer) As String
Dim iAlpha As Integer
Dim iRemainder As Integer
iAlpha = Int(iCol / 27)
iRemainder = iCol - (iAlpha * 26)
If iAlpha > 0 Then
CNumToLetter = Chr(iAlpha + 64)
End If
If iRemainder > 0 Then
CNumToLetter = CNumToLetter & Chr(iRemainder + 64)
End If
End Function

The line in red is the issue I'm getting, not quite sure how to correctly send values needed to a function
The error I get is ByRef Argument Type Mismatch

My HCCRange() function works and returns the integer value correctly trouble I believe is with what I stated

Sorry for the trouble still new at this
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi ,
Please change your function declaration like
Code:
[COLOR=#333333]Function CNumToLetter([B]ByVal[/B] iCol As Integer)
[/COLOR]

While calling the function please make sure that you declare StrClmData.

Code:
Dim StrClmData as String
StrClmData = CNumToLetter(intColumnData)

Hope it helps!
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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