Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Navigation Dilemma

Status
Not open for further replies.

Bass71

MIS
Jun 21, 2001
79
I am trying to write a Do-Loop statement in an Excel macro that starts in column A, populates cells along row 1 that meet the conditions and ends at AA. But it does not popluate any of the cells in row 1 - it immediately goes to AA1.
The code is as follows:

Range("A1").Select

Do Until Range("AA1").Select
If ActiveCell.Value = "" Then
ActiveCell.Value = ""","""
ActiveCell.Offset(0, 1).Select
Else
ActiveCell.EntireColumn.Select
Selection.Insert Shift:=xlToRight
ActiveCell.Value = ""","""
ActiveCell.Offset(0, 2).Select

End If

Loop

Thanks so much and Happy New Year!!
 
Its immediately going to cell $AA$1 because you are immediately selecting that cell in your Do..Until construct.

Is this what you are after (in terms of fixing the Do...Until)

[tt]
Range("A1").Select

Do Until ActiveCell.Address = "$AA$1"
If ActiveCell.Value = "" Then
ActiveCell.Value = ","
ActiveCell.Offset(0, 1).Activate

Else
ActiveCell.EntireColumn.Select
Selection.Insert Shift:=xlToRight
ActiveCell.Value = ","
ActiveCell.Offset(0, 2).Activate

End If

Loop
[/tt]

Cheers,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top