Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to list numbers


I have a column of numbers say 1 to 10 in column A
In column B at various rows there could be a number. This is the number
of times I need the number in column A repeated in column C eg.
"A2 to A20" have the numbers 1 to 19
if "A3"has the number 2 and "B3" has the number 4 then "C2 to C5"
should have number 2 in them. If the next number in column "B" was say
"B8" and this was 1 then "C6" would be 7

I have been trying to write a macro for this. I have got as far as
going down column A and identifying how many rows are populated and
then got stuck.
Help would be appreciated


--
tryer
------------------------------------------------------------------------
tryer's Profile: http://www.excelforum.com/member.php...o&userid=16546
View this thread: http://www.excelforum.com/showthread...hreadid=397592

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to list numbers


Try this. Is this is what you are looking for? Sorry if the code itself
is not vey good. I'm also a beginner.

Sub RepeatNumbers()

Dim lngLastRow As Long
Dim lngCount As Long
Dim lngRow As Long
Dim lngRepeat As Long
Dim lngRowAtC As Long
Dim lngValueAtA As Long

lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
lngRowAtC = 2
For lngRow = 2 To lngLastRow
lngValueAtA = Cells(lngRow, "A").Value
lngCount = Cells(lngRow, "B").Value
lngRepeat = 0
'lngRowAtC = lngRow - 1
If lngCount < 0 Then
Do Until lngRepeat = lngCount
Cells(lngRowAtC, "C").Value = lngValueAtA
lngRepeat = lngRepeat + 1
lngRowAtC = lngRowAtC + 1
Loop
End If
Next

End Sub


--
hideki
------------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...o&userid=18903
View this thread: http://www.excelforum.com/showthread...hreadid=397592

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
How can I extract a list of numbers missing in a list? Nancy New Users to Excel 2 January 28th 10 11:18 PM
change a vertical list of numbers to horizontal list from 1 cell caz Excel Discussion (Misc queries) 3 September 27th 06 12:11 PM
how to extract unique numbers once from a list of repeated numbers? [email protected] Excel Discussion (Misc queries) 2 May 2nd 06 04:17 PM
Macro to list numbers tryer[_2_] Excel Programming 1 August 21st 05 10:49 PM
How to create a macro that compares a list to another list Rampa New Users to Excel 1 January 13th 05 01:15 PM


All times are GMT +1. The time now is 10:17 PM.

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

About Us

"It's about Microsoft Excel"