View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Duke Carey
 
Posts: n/a
Default If than copy function / Macro

Try this code

There are instructions here for copying the code to your workbook:

http://www.contextures.com/xlvba01.html

David McRitchie has instructions for getting started with macros:

http://www.mvps.org/dmcritchie/excel/getstarted.htm





Sub CopyTextValues()
Dim rng As Range
Dim rngSource As Range
Dim x As Long
Dim y As Integer
Dim ws As Worksheet

Set rngSource = Selection

Set ws = ActiveWorkbook.Worksheets.Add

x = 1
For Each rng In rngSource
y = rng.Offset(0, 1)
If y 0 Then
ws.Cells(x, 1).Resize(y, 1) = rng
End If
x = x + y
Next rng

End Sub


"Sweetetc" wrote:

I have two worksheets.

The two columns that are as follows
Column A Column B
19765L819 2
19765H560 1
19765L538 0
19765N435 3

I want to create a function or macro that will list the numbers
in column A, the number of times indicated in column B
So the result of the above in a new worksheet column A
should look like:

19765L819
19765L819
19765H560
19765N435
19765N435
19765N435

Thanks
Liz
--
Thanks
ETC