ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   automatic row (https://www.excelbanter.com/excel-programming/324228-automatic-row.html)

Ralph

automatic row
 
I need to reserve rows and columns in a spreadsheet. What I need to do id,
say:

If Row 1, Column 1 has a value, say 2, two rows are to be automatically
reserved. If the value is 1, then 1 column/row is reserved. SOS please.

Tom Ogilvy

automatic row
 
Sub AddRows()
Dim max As Long, i As Long
Dim cnt As Long
max = 10
cnt = 0
i = 1
Do
If IsNumeric(Cells(i, 1)) And Not IsEmpty(Cells(i, 1)) Then
If Cells(i, 1).Value max Then
max = Cells(i, 1).Value + 1
End If
Cells(i, 1).Offset(1, 0).Resize(Cells(i, 1)).EntireRow.Insert
cnt = 0
Else
If IsEmpty(Cells(i, 1)) Then
cnt = cnt + 1
Else
cnt = 0
End If
End If
i = i + 1
Loop Until cnt max
End Sub

--
Regards,
Tom Ogilvy




"Ralph" wrote in message
...
I need to reserve rows and columns in a spreadsheet. What I need to do

id,
say:

If Row 1, Column 1 has a value, say 2, two rows are to be automatically
reserved. If the value is 1, then 1 column/row is reserved. SOS please.





All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com