Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Looping Question (I think?)

I think I need to write code to loop through my data, but cannot figure out
how to do this. What I need to do is, copy the number in column B down until
a different number is displayed, and then copy the new number down, etc. (ie
in the example below,for the Banana and Carrot entries, the corresponding
values in column B would be 548)

(Column A) (Column B)
Banana 548
Banana
Banana
Carrot
Carrot
Carrot
Carrot
Apple 635
Apple
Apple
Pear 589
Pear

Any and all assistance would be greatly appreciated.

Thank You,
MWS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Looping Question (I think?)

Hi MWS

Run this with a Sub test()
Dim L As Long
Dim C As Long
Dim V As Variant
C = 2
L = 1
Do Until Cells(L, 1).Value = ""
If Cells(L, C).Formula < "" Then
V = Cells(L, C).Formula
Else
Cells(L, C).Formula = V
End If
L = L + 1
Loop
End Sub

HTH. Best wishes Harald

"MWS" skrev i melding
...
I think I need to write code to loop through my data, but cannot figure

out
how to do this. What I need to do is, copy the number in column B down

until
a different number is displayed, and then copy the new number down, etc.

(ie
in the example below,for the Banana and Carrot entries, the corresponding
values in column B would be 548)

(Column A) (Column B)
Banana 548
Banana
Banana
Carrot
Carrot
Carrot
Carrot
Apple 635
Apple
Apple
Pear 589
Pear

Any and all assistance would be greatly appreciated.

Thank You,
MWS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Looping Question (I think?)

Grüezi MWS

MWS schrieb am 27.10.2004

What I need to do is, copy the number in column B down until
a different number is displayed, and then copy the new number down, etc. (ie
in the example below,for the Banana and Carrot entries, the corresponding
values in column B would be 548)

(Column A) (Column B)
Banana 548
Banana
Banana
Carrot
Carrot
Carrot
Carrot
Apple 635
Apple
Apple
Pear 589
Pear

Any and all assistance would be greatly appreciated.


Assuming your first value is in B1 then follow these steps:

Mark column B completly -- F5 -- [Contains...] (butteon bottom left of
the window) -- [x] empty cells -- [OK]

Now write the following formula:

=B1

and press Ctrl+Return

Mark column B completly again -- Copy -- Rightclick - insert values (or
similar) -- [x] values -- [OK]

--
Regards

Thomas Ramel
- MVP for Microsoft-Excel -

[Win XP Pro SP-1 / xl2000 SP-3]
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
Looping question Jase Excel Discussion (Misc queries) 2 March 19th 08 02:03 PM
Looping Question lee New Users to Excel 3 August 4th 06 04:23 PM
looping question luke New Users to Excel 4 June 3rd 05 01:19 PM
Looping question Rune_Daub[_8_] Excel Programming 1 November 8th 03 04:06 PM
Looping Question? Michael168[_56_] Excel Programming 2 November 7th 03 12:45 PM


All times are GMT +1. The time now is 01:32 PM.

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"