Operating Engineer

Closed
Shailesh - Apr 25, 2010 at 04:20 PM
rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 25, 2010 at 08:35 PM
Hello Ivan,

I was trying to find a macro for Range selection. I saw that you are Expert in making macros.

I am trying to make Macro to select Variable range for printing. I would like to select the range based on the cell values given in A1 and B1. Means If I write H5 in cell A1 and J20 in B1 and run a macro should select my range from H5 to J20.

If I write the value P3 in cell A1 and R15 in cell B1 then the macro should select my range from P3 to R15

Please help me to make the macro.

1 reply

rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 767
Apr 25, 2010 at 08:35 PM
Sub rangeSelect()

On Error Resume Next

Err.Clear

If (Range("A1") <> "") Then Range(Range("A1")).Select

If Err.code = 0 Then

If (Range("B1") <> "") Then Range(Range("B1")).Select

If Err.code = 0 Then

Range(Range("A1") & ":" & Range("B1")).Select
End If

End If

Err.Clear
On Error GoTo 0

End Sub
0