Set Range Variable to the value of a cell so user can input range in Excel Cell

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
83
I'm trying to set a Variable = to a range, but rather than defining the range in the code, I want to reference a cell in Excel. So I could go to the cell in Excel and type in "D4:D10" and that would become the range that the variable ='s
but then if I type into that cell in excel "D4:D15", NOW that would be the range the variable is = to.

Basically don't want to change the code every time I need to make a change to that range. I'd rather direct input it into a cell in Excel as it may come up frequently.

Code:
Dim WageRange As String


Dim LstRow1 As Integer
Dim LstRow2 As Integer
Dim LstRow3 As Integer
Dim LstRow4 As Integer     
        
        With Worksheets("Doc Request")
         Bor1 = .Range("B3").Value
         Bor2 = .Range("C3").Value
         Bor3 = .Range("D3").Value
         Bor4 = .Range("E3").Value
            Debug.Print Bor1
              Debug.Print Bor2
                Debug.Print Bor3
                  Debug.Print Bor4
        End With
        With Worksheets("Master")
        WageRange = .Range("B3").Value
        End With
        
        Debug.Print WageRange
        
[COLOR=#000000]                [/COLOR]
[B][COLOR=#000000]        Set Wage1 = Worksheets("Master").Range("WageRange")[/COLOR][/B]
        Set Self = Worksheets("Master").Range("B20:B25")
        Set Fixed1 = Worksheets("Master").Range("B27:B30")
        Set Fixed2 = Worksheets("Master").Range("B33:B39")

appreciate the help!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Something like
Code:
Sub chk()
Dim r As Range
Set r = Range(Range("F3").Value)
r.Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,321
Members
453,032
Latest member
Pauh

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