+ Reply to Thread
Results 1 to 11 of 11

Running Macro to copy Rows of Formulas

Hybrid View

cooh23 Running Macro to copy Rows of... 11-11-2007, 05:13 AM
VBA Noob See if link helps ... 11-11-2007, 05:16 AM
cooh23 I am sure the code should... 11-11-2007, 05:34 AM
VBA Noob You need to read this line... 11-11-2007, 05:47 AM
cooh23 Thank you! It worked! 11-11-2007, 06:12 AM
  1. #1
    Registered User
    Join Date
    11-11-2007
    Posts
    44

    Running Macro to copy Rows of Formulas

    Hello Everyone,

    Here's what I am doing:

    I have 2 speadsheets, I want to copy rows of Formulas from Spreadsheet 1 and copy them into Spreadsheet 2 but convert them into Values.

    Is it possible to create a button on Spreadsheet 1 and assign macro to do exactly what i want? I also want the macro to look for the first empty row in the database so that the information being copied are on the next row and not overwritten.

    I hope I am making sense.

    Thanks for your help in advance!

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See if link helps

    http://www.rondebruin.nl/copy1.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    11-11-2007
    Posts
    44
    Quote Originally Posted by VBA Noob
    See if link helps

    http://www.rondebruin.nl/copy1.htm

    VBA Noob
    I am sure the code should work but because I am new to macro's, I might be missing something here.

    Here's what I want to do, I want to copy the information from Row number 1 located in the sheet called IWLog and paste the information in an empty row as Values in the sheet called Log.

    Thank you.

    Here's my code:
    Sub Copy_1_Value_PasteSpecial()
        Dim SourceRange As Range, DestRange As Range
        Dim DestSheet As Worksheet, Lr As Long
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        'fill in the Source Sheet and range
        Set SourceRange = Sheets("IWLog").Range("A1:Z1")
    
        'Fill in the destination sheet and call the LastRow
        'function to find the last row
        Set DestSheet = Sheets("Log")
        Lr = LastRow(DestSheet)
    
        'With the information from the LastRow function we can
        'create a destination cell
        Set DestRange = DestSheet.Range("A" & Lr + 1)
    
        'Copy the source range and use PasteSpecial to paste in
        'the destination cell
        SourceRange.Copy
        DestRange.PasteSpecial xlPasteValues, , False, False
        Application.CutCopyMode = False
    
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    
    End Sub
    Last edited by cooh23; 11-11-2007 at 05:42 AM.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    You need to read this line again

    Important: The macro examples use one function or two functions that you can find in the last section of this page.
    As you forgot to add

    Function LastRow(sh As Worksheet)
        On Error Resume Next
        LastRow = sh.Cells.Find(What:="*", _
                                After:=sh.Range("A1"), _
                                Lookat:=xlPart, _
                                LookIn:=xlFormulas, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlPrevious, _
                                MatchCase:=False).Row
        On Error GoTo 0
    End Function
    or Instead of a function you can also check one row or column to find the last cell with a value.

    Replace this line:
    Lr = LastRow(DestSheet)
    With:
    Lr = DestSheet.Cells(Rows.Count, "A").End(xlUp).Row
    VBA Noob

  5. #5
    Registered User
    Join Date
    11-11-2007
    Posts
    44
    Thank you!
    It worked!

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Your welcome

    VBA Noob

+ 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