ByRef

andyjames

Board Regular
Joined
May 15, 2007
Messages
133
I have the following code but it is giving me a 'ByRef Type Argument Type Mismatch' error.
Can someone help me locate the error? (range_text is a text box)

private sub borders_cmd_click()

Dim u, v, w, x, y, z As Boolean
{the variable are then given boolean value}
Borders (range_text), u, v, w, x, y, z

End Sub

Sub Borders(rng As Range, a As Boolean, b As Boolean, c As Boolean, d As Boolean, e As Boolean, f As Boolean)

{code}

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You have to repeat the type for each variable:

Dim u As Boolean, v As Boolean, w As Boolean, x As Boolean, y As Boolean, z As Boolean
 
Upvote 0
Ok, couple of things, firstly your variable declaration:
Code:
Dim u, v, w, x, y, z As Boolean
Is not doing what you think, it is declaring z as Boolean and u,v,w,x, & y as Variants. It doesn’t make a great deal of difference here but something to note for the future, you would need to declare them like so:
Code:
Dim u as Boolean, v as Boolean, w as Boolean, x as Boolean, y as Boolean, z as Boolean

Secondly, I think your problem is possibly:
Code:
Borders (range_text), u, v, w, x, y, z
Should be:
Code:
Borders (range_text, u, v, w, x, y, z)

Hope that helps!
 
Upvote 0
thank you
I'm sure I had used that technique previously.
however, it has got rid my initial error.
but now I have a run-time 'type mis-match' error.

any further errors that you can see with my code?
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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