Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic VBA Question

Status
Not open for further replies.

maccten2000

Programmer
May 13, 2003
37
EU
Hi All,

Basically I have macro that calls a function
I want to make this function as generic as possible for maybe someday being able to use it in future for something else

I want to pass in a variable of cell ranges like for example "A1:B2"
I then wish to subtitute the static "A1:B2" variable in the function with the passed in variable so a practical rough example is below for clarity

Code:
dim strRange "A1:B2"

x = SelectRange (strRange)

function SelectRange(strRange) as boolean

SelectRange = Range(strRange).Select

end function

My concern is the qoutes seem to be causing issues and it doesnt seem to accept it if i try and manufacture qoutes around the variable

Any help would be greatly appreciated

Thanks

 
What issue(s) are you seeing? Apart from a slight syntax change to separate the Dim and the assignment, your code should work. It's hard to say more as the posted code does nothing of consequence.


Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Option Explicit

Sub cc()
Dim strRange As String, x As Boolean
strRange = "A1:B2"
x = SelectRange(strRange)
End Sub

Function SelectRange(strRange) As Boolean
SelectRange = Range(strRange).Select
End Function

Candu si tene su 'entu es prezisu bentolare.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top