using a concatenated name as argument in function

kvsatyam

New Member
Joined
Jun 19, 2014
Messages
1
I am trying to pass an argument to a function where the argument is concatenated. it is not working .
Can any body help.

The function code is
------------------------------------
Function degf(ByRef x As Variant)
degf = x * 1.8 + 32
End Function
-----------------------------------
Sub temperature1()
Dim p1, p2, p3, p4, i As Integer
p1 = 2
p2 = 3
p3 = 4
p4 = 5
For i = 1 To 4
q = "p" & i
ActiveSheet.Cells(3, i) = q
ActiveSheet.Cells(4, i) = degf(q)
Next i
ActiveSheet.Cells(2, 1) = "Temperature in deg C"
ActiveSheet.Cells(2, 3) = "temperature in def"

End Sub
--------------------------------------------
when i am trying to execute an error 13 of type mismatch come.i tried several ways but not succeeded.
Please help
thanks in advance
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You can't do that. You could simply use an array though:

Code:
Sub temperature1()
Dim p(1 to 4), i As Integer
p(1) = 2
p(2) = 3
p(3) = 4
p(4) = 5
For i = 1 To 4
q = p(i)
ActiveSheet.Cells(3, i) = q
ActiveSheet.Cells(4, i) = degf(q)
Next i
ActiveSheet.Cells(2, 1) = "Temperature in deg C"
ActiveSheet.Cells(2, 3) = "temperature in def"

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,537
Members
449,088
Latest member
RandomExceller01

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