ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro If Statement (https://www.excelbanter.com/excel-programming/355702-macro-if-statement.html)

mark64

Macro If Statement
 
I am new to VBA and don't have much experience in creating code, however what
I am trying to do I have seen in other people's excel sheets, but they were
password protected and so I couldn't look at them. Here is what I am trying
to do:

I have a cell, say "A1" that requires an input. There is a set of equations
in a table in the same excel spreadsheet. When the input is entered, say
"5", and then a button is pressed, the 5 rows are added to the table and the
equations are copied down.

So I think I need an if statement based on the "A1" input. Or should this
be a loop statement.

Thanks in advance for any help on this.



Otto Moehrbach

Macro If Statement
 
If I am reading you correctly, you said you want 5 rows added to the table.
The bottom of the table?? Lots of blank rows are already there.
I assumed your table was from Column D to Column G. This macro will copy
the formulas from the last row of the table to a number of rows down equal
to the number in A1. Make this message full screen to avoid line wrapping.
HTH Otto
Sub Macro1()
Range("D" & Rows.Count).End(xlUp).Resize(, 4).Copy
Range("D" &
Rows.Count).End(xlUp).Offset(1).Resize(Range("A1") .Value).PasteSpecial
End Sub
"Mark64" wrote in message
...
I am new to VBA and don't have much experience in creating code, however
what
I am trying to do I have seen in other people's excel sheets, but they
were
password protected and so I couldn't look at them. Here is what I am
trying
to do:

I have a cell, say "A1" that requires an input. There is a set of
equations
in a table in the same excel spreadsheet. When the input is entered, say
"5", and then a button is pressed, the 5 rows are added to the table and
the
equations are copied down.

So I think I need an if statement based on the "A1" input. Or should this
be a loop statement.

Thanks in advance for any help on this.





Otto Moehrbach

Macro If Statement
 
Line wrapping messed it up anyway. The macro consists of 4 lines. The
second line ends with "Copy". The third line ends with "PasteSpecial".
HTH Otto
"Otto Moehrbach" wrote in message
...
If I am reading you correctly, you said you want 5 rows added to the
table. The bottom of the table?? Lots of blank rows are already there.
I assumed your table was from Column D to Column G. This macro will copy
the formulas from the last row of the table to a number of rows down equal
to the number in A1. Make this message full screen to avoid line
wrapping. HTH Otto
Sub Macro1()
Range("D" & Rows.Count).End(xlUp).Resize(, 4).Copy
Range("D" &
Rows.Count).End(xlUp).Offset(1).Resize(Range("A1") .Value).PasteSpecial
End Sub
"Mark64" wrote in message
...
I am new to VBA and don't have much experience in creating code, however
what
I am trying to do I have seen in other people's excel sheets, but they
were
password protected and so I couldn't look at them. Here is what I am
trying
to do:

I have a cell, say "A1" that requires an input. There is a set of
equations
in a table in the same excel spreadsheet. When the input is entered, say
"5", and then a button is pressed, the 5 rows are added to the table and
the
equations are copied down.

So I think I need an if statement based on the "A1" input. Or should
this
be a loop statement.

Thanks in advance for any help on this.








All times are GMT +1. The time now is 10:41 AM.

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