We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Excel Macros - Help Needed

Options
2»

Comments

  • paddyrg
    paddyrg Posts: 13,543 Forumite
    Do you have any choice about the file format? Just I think Excel actually sounds like the wrong tool for the job truth be told. Sending a workbook with sheets with a header row and one line of data sounds like the system could be reviewed and better options found with a bit of consideration.

    What do we actually want to achieve? Do the people sending the sheets fill them in daily by hand? Or some kind of template? Would they fill in a web form instead? If so, you could set up a google docs spreadsheet with a 'form' in about 30 mins, and that does exactly what you describe, you would just send the form link to everyone, it would automatically add a new row each time for each form submission.

    Or get the datagrams submitted in simple xml, or even csv files and have a bulk import job into a database

    And a database sounds like the right place for this data to be going, not into rows in a worksheet. Or maybe, anyway, as I don't know the exact circumstances - but from my years in data migrations and data-aware applications, everything you describe feels wrong in my guts and suggests there is a much better answer out there for the sake of thinking about it a little.
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    As a quick and very simple macro, this should go some way to solve your problem. I've assumed all workbooks will be open in the same instance of Excel.
    Sub copy_across()
    Dim wb1 As Workbook, wb2 As Workbook, ws1 As Worksheet, ws2 As Worksheet
    Set wb1 = ThisWorkbook
    Set ws1 = wb1.ActiveSheet
    Set wb2 = Workbooks("Your_workbook_name")
    Set ws2 = wb2.ActiveSheet
    ws2.Rows("2:2").Copy Destination:=ws1.Range("A65535").End(xlUp).Offset(1, 0)
    Application.CutCopyMode = False
    Set ws1 = Nothing
    Set ws2 = Nothing
    Set wb1 = Nothing
    Set wb2 = Nothing
    End Sub

    You'll need to change the name of "Book2" to whatever your workbook is called but that should give you basically what you want.
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • LucianH
    LucianH Posts: 445 Forumite
    Part of the Furniture 100 Posts Name Dropper Photogenic
    rmg1 wrote: »
    As a quick and very simple macro, this should go some way to solve your problem..

    Nice one:
    ws2.Rows("2:2").Copy Destination:=ws1.Range("A65535").End(xlUp).Offset( 1, 0)
    Application.CutCopyMode = False

    Very elegant
    Never let it get you down... unless it really is as bad as it seems.
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    LucianH - Thanks. You wouldn't believe how many times I've come across this scenario and this is what I've managed to pare my code down to.

    It does actually help that the files aren't stored on a drive in the first place as you don't have to worry about trying to find them.
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 351K Banking & Borrowing
  • 253.1K Reduce Debt & Boost Income
  • 453.6K Spending & Discounts
  • 244K Work, Benefits & Business
  • 599K Mortgages, Homes & Bills
  • 176.9K Life & Family
  • 257.4K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.