ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Loop of Doom ARRRG! (https://www.excelbanter.com/excel-discussion-misc-queries/212971-loop-doom-arrrg.html)

jlclyde

Loop of Doom ARRRG!
 
I was unable to make this loop work the way that I wanted to. TO make
it work I had to add a Goto. I hate these but find them necessary
when I get stuck in a loop. I was trying to find the last column in a
row that has information in it and then putting my information in the
next column. Any thoughts?
Thanks,
Jay
x = 12
Do
If Log.Cells(QuoteRow, x).Offset(0, 1) = "" Then
Log.Cells(QuoteRow, x).Offset(0, 1) = Dt
GoTo E
Else
x = x + 1
End If
Loop Until Log.Cells(QuoteRow, x) = ""

E:

Jarek Kujawa[_2_]

Loop of Doom ARRRG!
 
try

Do Until Cells(QuoteRow, x) = ""
If Cells(QuoteRow, x).Offset(0, 1) = "" Then
Cells(QuoteRow, x).Offset(0, 1) = Dt
GoTo E
Else
x = x + 1
End If
Loop

Gary''s Student

Loop of Doom ARRRG!
 
Loop not needed:

Sub dural()
Dim QuoteRow As Long
QuoteRow = 13
n = Cells(QuoteRow, Columns.Count).End(xlToLeft).Column
Cells(QuoteRow, n + 1).Value = Cells(QuoteRow, n).Value
End Sub

--
Gary''s Student - gsnu200819

JE McGimpsey

Loop of Doom ARRRG!
 
One way:

Replace your entire code with

Log.Cells(QuoteRow, Columns.Count).End(xlToLeft)(1, 2).Value = Dt

In article
,
jlclyde wrote:

I was trying to find the last column in a row that has information in
it and then putting my information in the next column. Any thoughts?



All times are GMT +1. The time now is 02:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com