Input box to select column

T

transferxxx

Sub Test()

Dim c As Range
Dim rng As Range
Dim rng1 As Range

Set rng = Intersect(Range("Print_Area"), Range("F:F"))
Set rng1 = rng.Offset(1).Resize(rng.Rows.count - 1)

For Each c In rng1
If c.value <> c.Offset(1).value Then
ActiveWindow.SelectedSheets.HPageBreaks.Add
Before:=c.Offset(1)
End If
Next
End Sub

How can I modify the above code - so that an inputbox appears allowing
me to select my column i.e replacing Range("F:F") with my selected
column

thxs
 
G

Guest

hi,
something like this might work...

inp = InputBox("enter a column letter")

Replace Range("F:F") with Columns(inp).

regards
FSt1
 
N

NickHK

If you use this, you can allow the user to select a range

Dim TheRange As Range
Const RangeOnly As Long = 8
Set TheRange=Application.Inputbox("Some prompt",,,,,,RangeOnly)
If Not TheRange Is Nothing Then
'Continue

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top