Selecting Variable Row Range w/Macro

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

I currently need to change the following so that I can
select a variable amount of rows, rather than 1 column. I
am sure that it has to do with the str_column, but can not
figure out how! this is the script I am presently working
with:

Const target_wb = "VCS Merge Data WORKBOOK.xls"
Dim str_column
Dim file_name
Dim source_wb
Dim str_search As String
Dim str_replace As String

file_name = Application.GetOpenFilename
Workbooks.Open Filename:=CStr(file_name)
source_wb = ActiveWindow.Caption
str_column = InputBox("Enter your column to copy")
str_column = str_column & ":" & str_column
 
Hi Steve

You can use this in your code

Sub test()
Dim mycell As Range
Set mycell = Application.InputBox( _
prompt:="Select a range", Type:=8)

' mycell.Copy Sheets("Sheet2").Range("A1")

End Sub
 
Steve,

Untested.

Const target_wb = "VCS Merge Data WORKBOOK.xls"
Dim str_column
Dim file_name
Dim source_wb
Dim str_search As String
Dim str_replace As String

file_name = Application.GetOpenFilename
Workbooks.Open Filename:=CStr(file_name)
source_wb = ActiveWindow.Caption
str_column = InputBox("Enter your column to copy")

Cells(1,str_column).Resize(Cells(Rows.Count,str_column).End(xlUp).Row).Selec
t

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Take a look at the InputBox method of the Application
object using Type 8 in the help file. That might be
better for what you're trying to do.

-Brad
 
Back
Top