VBScript - set variable to specific sheet

HiTekRedNek

New Member
Joined
Jan 11, 2010
Messages
21
Hi,

I'm trying to modify a ping script to grab a range of IP addresses from a spreadsheet (all listed IP's start on Row 2, Column 2) and append the result to the same worksheet (starting at Row 2, Column 6).

The first part of the script sets the variable.

Code:
set XL = CreateObject ("Excel.Application")
XL.Visible = true
XL.DisplayAlerts = false
set Sheet = XL.Workbooks.Open _
("C:\dev_offline_01112009.csv").Sheets(1)

Is this the proper way to open the csv and refer to sheet 1? During the next part of the script I want do perform a do loop that references the "Sheet" variable to go through the list of IP addresses found in Column 2.

Code:
do
set Cell = Sheet.Cells (2,2)
if Cell <> ""  then
call Ping

Am I on the right track?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi HiTekRedNek,

Sheets(1) refers to the first worksheet in the workbook, regardless of its name. If you need to refer to the worksheet named 'Sheet1', use Sheets("Sheet1").
 
Upvote 0

Forum statistics

Threads
1,225,476
Messages
6,185,200
Members
453,283
Latest member
Shortm88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top