macro help
Thanks, I made a few tweaks and got it to work.
--
Regards,
timmulla
"Office_Novice" wrote:
Try this.
Sub DoStuff()
Dim YourRange As Range
Dim ALastrow As Long
Dim i As Variant
Dim ws As Worksheet
Dim x, j As Integer
Dim yourVar As Integer
ALastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set YourRange = Range("B1:B" & ALastrow)
Set ws = ActiveWorkbook.Worksheets(1)
For Each i In YourRange
yourVar = i.Offset(0, -1).Value
If i.Offset(0, -1).Value = "0" Then
i.Offset(0, 1).Value = i.Offset(0, -1).Value
For j = 1 To yourVar
i.Offset(0, 2).Cells.Insert Shift:=xlDown
i.Offset(0, 2).Value = "1"
Next j
End If
Next i
End Sub
"timmulla" wrote:
I would greatly appreciate if somebody could help me out creating a macro.
I need to create a lastRow variable from column B. Im not sure if this will
work.
Dim lastRow As String
lastRow = Range(B2).End(xlDown).Row
Then I need to loop from A2 to A & lastRow.
During the loop:
If it finds a number 0 in column A
Then store the corresponding number two cells to the right (column C) as a
variable.
Then go over to column D and place number 1s downward (as many times as the
stored variable number).
Any help would be appreciated
--
Regards,
timmulla
|