+ Reply to Thread
Results 1 to 3 of 3

Fixing the VBA code

Hybrid View

  1. #1
    Registered User
    Join Date
    05-24-2012
    Location
    Phoenix, Arizona
    MS-Off Ver
    2010
    Posts
    17

    Fixing the VBA code

    Push.xlsm
    Attached is a sample file of what I am looking to accomplish.
    On the sheet 'Enter' there is a button control to a VBA macro that allows the information entered into sheet'Enter' to tally onto sheet 'Tally 1'.
    Also on sheet 'Enter' cell A10 says SHEET. I would like to enter the sheet name into cell C10 and have the VBA code add the information into the correct sheet. I am at a loss at to how to get the information to the correct sheet.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Fixing the VBA code

    Sub tally()
    Dim lrow As Long, i As Long
    
        With Worksheets(Worksheets("Enter").Range("C10").Value)
            lrow = .Range("A" & .Rows.Count).End(xlUp).Row
            For i = 2 To lrow
                .Range("B" & i).Value = .Range("B" & i).Value + Worksheets("Enter").Range("B" & i).Value
                Worksheets("Enter").Range("B" & i).Value = 0
            Next i
        End With
    End Sub

  3. #3
    Registered User
    Join Date
    05-24-2012
    Location
    Phoenix, Arizona
    MS-Off Ver
    2010
    Posts
    17

    Re: Fixing the VBA code

    Bob, you are the man. Worked perfectly. Thanks a lot.

+ 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