Urgent Access Loop through Excel on a row

T

Trever B

Hi,

Thanks in advance

What I have at present looks at cells A1 G2 & F3.

What i Need is to have a loop that looks at just a row, lets say row 4 ie
A4,B4, C4 all the way to the end. Not sure I how I refer it cells in a loop
situation and (More to the point where should I be looking to find out)

Dim objBook As Object
Dim objSheet As Object


Set objBook = GetObject("C:\ExcellFiles\Test_Case.xls")

For Each objSheet In objBook.Worksheets 'each worksheet

With objSheet

WorkSheet = .Name
Range = .UsedRange.Address
CellA1 = .UsedRange.Cells(1, 1).formula
CellF3 = .UsedRange.Cells(3, 6).formula
CellG2 = .UsedRange.Cells(2, 7).formula

End With

'do work here


Next

Set objSheet = Nothing
objBook.Close False
Set objBook = Nothing






Trev
 
B

Barry Gilbert

You can use a variable in place of the column number in the cells property.
For example:
For i = 1 to 15
Debug.Print Worksheets("MySheetName").Cells(4, i)
Next

You can fnd help on Excel VBA by opening the VBA editor in Excel and opening
help. Tons of good examples there.

HTH,
Barry
 

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