+ Reply to Thread
Results 1 to 3 of 3

macro

Hybrid View

  1. #1
    Joel
    Guest

    macro

    Hello,

    I want to run a macro that does this"

    On sheet 1, I fill in A1 with data. I click a button and it copies it over to A1 on sheet 2.

    Then, on sheet 1, I fill in A1 with something else. I click the button again and it copies it into the next available row which would be A2.

    Can someone please point me in the right direction.

    Thanks so much,
    Joel

  2. #2
    DB
    Guest

    RE: macro

    Joel,

    Try this. Open a new workbook and place a button on the sheet. Right click
    on the button and click properties. Change the name to btnSendToSheet2. If
    you double click your button the VBE will open. Copy the following code and
    give it a try.

    Private Sub btnSendToSheet2_Click()
    Dim vData As Variant
    Dim lRow As Long

    vData = Cells(1, 1)
    With Sheets(2)
    lRow = .UsedRange.Rows.Count
    If IsEmpty(.Cells(1, 1)) Then
    .Cells(1, 1) = vData
    Else
    .Cells(lRow + 1, 1) = vData
    End If
    End With

    End Sub

    "Joel" wrote:

    > Hello,
    >
    > I want to run a macro that does this"
    >
    > On sheet 1, I fill in A1 with data. I click a button and it copies it over to A1 on sheet 2.
    >
    > Then, on sheet 1, I fill in A1 with something else. I click the button again and it copies it into the next available row which would be A2.
    >
    > Can someone please point me in the right direction.
    >
    > Thanks so much,
    > Joel


  3. #3
    Joel
    Guest

    RE: macro

    Thank you so much for your help. You were more help than you know!
    -Joel

    "DB" wrote:

    > Joel,
    >
    > Try this. Open a new workbook and place a button on the sheet. Right click
    > on the button and click properties. Change the name to btnSendToSheet2. If
    > you double click your button the VBE will open. Copy the following code and
    > give it a try.
    >
    > Private Sub btnSendToSheet2_Click()
    > Dim vData As Variant
    > Dim lRow As Long
    >
    > vData = Cells(1, 1)
    > With Sheets(2)
    > lRow = .UsedRange.Rows.Count
    > If IsEmpty(.Cells(1, 1)) Then
    > .Cells(1, 1) = vData
    > Else
    > .Cells(lRow + 1, 1) = vData
    > End If
    > End With
    >
    > End Sub
    >
    > "Joel" wrote:
    >
    > > Hello,
    > >
    > > I want to run a macro that does this"
    > >
    > > On sheet 1, I fill in A1 with data. I click a button and it copies it over to A1 on sheet 2.
    > >
    > > Then, on sheet 1, I fill in A1 with something else. I click the button again and it copies it into the next available row which would be A2.
    > >
    > > Can someone please point me in the right direction.
    > >
    > > Thanks so much,
    > > Joel


+ 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