Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default End of data loop

Hi guys,

I need help with this specific macro i've bene tyring to get right.
I've been doing it in my head in pseudo-code but can't seem to figure
out the proper syntax in excel i guess.

I have multiple rows of data and I want to loop through them and insert
specific formules.

In my head, its something like this

integer x=2
while(A(x) is not null) do
C(x) = <formula
D(x) = <formula
E(x) = <formula
x++
end while

Can anyone give me a few pointers?

Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default End of data loop

Hi,

Some examples: The first is virtual your pseudo code. The second finds
the last non-blank row in column A and loops through all rows; the third is
si,ilar but assigns the same formula (or any data) to there consecutive
columns e.g C, D and E.

HTH

Sub DoLoop1()
Dim r As Long
r = 2
Do While Cells(r, "A") < ""
Cells(r, "C") = "Formula 1"
Cells(r, "D") = "Formula 2"
Cells(r, "E") = "Formula 3"
r = r + 1
Loop

End Sub
Sub DoLoop2()

Dim r As Long, lastrow As Long
' Find last non-blank row starting from bootom of column
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
' Loop through all rows, starting at 2
For r = 2 To lastrow
Cells(r, "C") = "Place Formula here" 'Assign a formula to col C, row r
Cells(r, "D") = "Place Formula here" 'Assign a formula to col D, row r
Cells(r, "E") = "Place Formula here" 'Assign a formula to col E, row r
Next r

End Sub
Sub DoLoop3()

Dim r As Long, lastrow As Long
' Find last non-blank row starting from bootom of column
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
' Loop through all rows, starting at 2
For r = 2 To lastrow
Cells(r, "C").Resize(1, 3) = "Place Formula here" 'Assign SAME formula
to cols C,D & E in row r
Next r

End Sub

"mortals" wrote:

Hi guys,

I need help with this specific macro i've bene tyring to get right.
I've been doing it in my head in pseudo-code but can't seem to figure
out the proper syntax in excel i guess.

I have multiple rows of data and I want to loop through them and insert
specific formules.

In my head, its something like this

integer x=2
while(A(x) is not null) do
C(x) = <formula
D(x) = <formula
E(x) = <formula
x++
end while

Can anyone give me a few pointers?

Thanks in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default End of data loop

Sub ABCD()
Dim x as Long
x = 2
Do while not isemtpy(cells(x,"A"))
Cells(x,"C").formula = "=Formula"
Cells(x,"D").formula = "=Formula"
Cells(x,"E").Formula = "=formula"
x = x + 1
Loop
end Sub

--
Regards,
Tom Ogilvy


"mortals" wrote in message
oups.com...
Hi guys,

I need help with this specific macro i've bene tyring to get right.
I've been doing it in my head in pseudo-code but can't seem to figure
out the proper syntax in excel i guess.

I have multiple rows of data and I want to loop through them and insert
specific formules.

In my head, its something like this

integer x=2
while(A(x) is not null) do
C(x) = <formula
D(x) = <formula
E(x) = <formula
x++
end while

Can anyone give me a few pointers?

Thanks in advance



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default End of data loop

Awesome, the loops seems to work but I have run into another
cinderblock.

This is an example of one of the formulas that I am using based on what
you guys passed on to me.

Cells(x, "C").Formula = "=(Data!Cells(x, "P")+Data!Cells(x,"R")/24"

It keeps giving me a compiled error, unexpected end of statement. It
keeps pointing to the P and I can't figure out how to get around it.
I've tried single quotation marks, putting them in separate brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help would be
appreciated.


-Simon the newbie

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default End of data loop

Mortals,

You need to use a double-double quote mark - "" to include a quote within a
text string.

".....(x,""P.....



"mortals" wrote:

Awesome, the loops seems to work but I have run into another
cinderblock.

This is an example of one of the formulas that I am using based on what
you guys passed on to me.

Cells(x, "C").Formula = "=(Data!Cells(x, "P")+Data!Cells(x,"R")/24"

It keeps giving me a compiled error, unexpected end of statement. It
keeps pointing to the P and I can't figure out how to get around it.
I've tried single quotation marks, putting them in separate brackets
and what not but it doesn't work. =/ I'm stumped, guys. Help would be
appreciated.


-Simon the newbie


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop through Filtered Data MJRay Excel Programming 1 March 1st 05 05:04 PM
Need help with loop to import data silvest Excel Programming 1 September 23rd 04 03:16 PM
Need help with loop to import data silvest[_2_] Excel Programming 0 September 23rd 04 03:16 PM
Checking data with a loop Syrus the Virus[_4_] Excel Programming 1 January 12th 04 11:40 AM


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"