Now, if you were intending to do more with that worksheet then these
are some common variables that I use:
option explicit
public sub do_stuff_with_wb()
dim wb as workbook
dim ws as Worksheet
dim r as range
set wb = Workbooks.open("wb_path\wb_name.xls")
set ws = wb.activesheet ' uses the active sheet of the workbook just
opened
set ws = wb.sheets(2) ' uses the second sheet of the workbook
set ws = wb.sheets.add
ws.name = "your_sheet"
set r = ws.range("A1") ' r points to cell A1 of your_sheet
set r = ws.offset(2,2) ' moves two rows down and two colums right
(C3)
set r = ws.offset(-1,-1) ' moves one row up and one column left (B2)
r.value = "Hi!" ' sets the value of B2 to "Hi!"
set r = nothing
set ws = nothing
set wb = nothing
end sub
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.