+ Reply to Thread
Results 1 to 3 of 3

Macro If Statement

  1. #1
    Mark64
    Guest

    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.



  2. #2
    Otto Moehrbach
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >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.
    >
    >




  3. #3
    Otto Moehrbach
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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" <[email protected]> wrote in message
    > news:[email protected]...
    >>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.
    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1