+ Reply to Thread
Results 1 to 4 of 4

Using GOTO to first empty cell in a macro

  1. #1
    Registered User
    Join Date
    05-21-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    94

    Using GOTO to first empty cell in a macro

    I am planning to write a macro which joins two worksheets. It will first open Worksheet 1 then go to the first emty cell. Next it will open Worksheet 2 and copy its contents to the first emty cell in Worksheet 2. This is a very basic descriprion of a more complex macro. My question is as follows: if I add rows to worksheet 1 will the macro copy worksheet 2 to the first empty cell in Worksheet 1 or will it always go to the cell it found when I first ran the macro? If the latter it would mean that the new rows in Worksheet 1 would be overwritten.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,442

    Re: Using GOTO to first empty cell in a macro

    If you record a macro, it will always do the same thing with hard coded cells and ranges. If you write a macro yourself, you can make it more flexible and generic.

    Finding the last row of data or the next available cell are common tasks that are done all the time.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-21-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    94

    Re: Using GOTO to first empty cell in a macro

    Although I have been using Excel for thirty years or more I have never written a macro, instead I record them. Rather than spending hour teaching myself to write a macro I have come up with a different method of achieving the same result. The macro I record will open the first worksheet (Worksheet 1), find the last cell containing data, page down several hundred rows then save the result as a new worksheet (Worksheet 1a). It will then open the second worksheet (Worksheet 2), highlight all the cells and copy them to the bottom of Worksheet 1a before sorting the combined data and saving the result as Worksheet 3. It will be more complicated than this as I also want to add data from yet another worksheet which has the same data but arranged in different order.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,442

    Re: Using GOTO to first empty cell in a macro

    This code will copy the data from one worksheet (2) to the bottom of the data on another worksheet (1). In this example, both worksheets are in the same workbook with the code. An example is given for opening the second workbook.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Help (IF A1 = Yes goto cell b100...)
    By nono5551212 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-17-2013, 10:30 PM
  2. [SOLVED] Goto to cell macro
    By jonrack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2012, 02:21 PM
  3. Macro goto next blank cell
    By staples in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-20-2009, 11:09 AM
  4. VBA code to goto first empty cell on opening a workbook.
    By tony0710 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2009, 01:29 PM
  5. How do you Parse the contents of a cell into a macro goto?
    By hoopsinoz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-19-2008, 10:11 PM
  6. Goto a dynamic cell address within a macro
    By blkane in forum Excel General
    Replies: 3
    Last Post: 06-08-2005, 03:05 PM
  7. [SOLVED] Goto a dynamic cell address within a macro
    By blkane in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-08-2005, 02:05 PM

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