Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49972

Convert string to Range

$
0
0
I have a large range of cells I need to define:


Code:

    Dim D_KeyCells As Range
    Dim E_KeyCells As Range
    Dim G_KeyCells As Range
    Dim I_KeyCells As Range
    Dim J_KeyCells As Range
    Dim K_KeyCells As Range
    Dim L_KeyCells As Range
    Dim M_KeyCells As Range

and then set the ranges (Witch are basically the same:

Code:

    Set D_KeyCells = Range("D6:D16")
    Set E_KeyCells = Range("E6:E16")
    Set G_KeyCells = Range("G6:G16")
    Set I_KeyCells = Range("I6:I16")
    Set J_KeyCells = Range("J6:J16")
    Set K_KeyCells = Range("K6:K16")
    Set L_KeyCells = Range("L6:L16")
    Set M_KeyCells = Range("M6:M16")


I was trying to simplify everything by doing the following (So the above code would not be needed)

I am using this code to grab the current cell column letter
Code:

C_C = Split(ActiveCell(1).Address(1, 0), "$")(0)
and I was trying to use some code like this to create the Range based on the column letter
Code:

CurrentRange = "Range(" & Chr(34) & C_C & "6:" & C_C & "16" & Chr(34) & ")"
but how can I change that into something I can then use for this:

Code:

If Not Application.Intersect(CurrentRange, Range(Target.Address)) Is Nothing Then
      Call C_C & "_CheckRow"  'So it would be calling D_CheckRow, or E_Check_row, ect..
End If


Viewing all articles
Browse latest Browse all 49972

Trending Articles