Hello an thank you for a great forum that has helped me alot.
I have a macro that looks almost exatly like the one in this thread https://www.mrexcel.com/forum/excel-questions/793062-modify-vba-suit.html
I just want the range to be the column that I am currently in.
How to do this?
Example of files that I want to change.
Sometimes the number is in another column C, D, E or whatever.
So I want to place the marker in a cell in that column,
and use the macro to make empty rows acording to the info in the column with the number.
Column A Column B Column C
Hello 5
MrExcel 4
How 5
Are 3
You 4
The rows with Range "B" is what I mean.
Dim lngStartRow As Long
Dim lngEndRow As Long
Dim m As Integer
Dim n As Long
With ActiveSheet
'work from bottom up
'set start row
lngStartRow = Range("B" & CStr(Application.Rows.Count)).End(xlUp).Row
'set end row
lngEndRow = 1
'loop through all used rows in column B starting at bottom
For n = lngStartRow To lngEndRow Step -1
If IsNumeric(Range("B" & CStr).Value) Then
'insert rows below
For m = 2 To Range("B" & CStr).Value
Rows(n + 1).Insert
Next m
End If
Next n
End With
End Sub
I have a macro that looks almost exatly like the one in this thread https://www.mrexcel.com/forum/excel-questions/793062-modify-vba-suit.html
I just want the range to be the column that I am currently in.
How to do this?
Example of files that I want to change.
Sometimes the number is in another column C, D, E or whatever.
So I want to place the marker in a cell in that column,
and use the macro to make empty rows acording to the info in the column with the number.
Column A Column B Column C
Hello 5
MrExcel 4
How 5
Are 3
You 4
The rows with Range "B" is what I mean.
Dim lngStartRow As Long
Dim lngEndRow As Long
Dim m As Integer
Dim n As Long
With ActiveSheet
'work from bottom up
'set start row
lngStartRow = Range("B" & CStr(Application.Rows.Count)).End(xlUp).Row
'set end row
lngEndRow = 1
'loop through all used rows in column B starting at bottom
For n = lngStartRow To lngEndRow Step -1
If IsNumeric(Range("B" & CStr).Value) Then
'insert rows below
For m = 2 To Range("B" & CStr).Value
Rows(n + 1).Insert
Next m
End If
Next n
End With
End Sub