1. Please take 30 seconds to register your free account to remove most ads, post topics, make friends, earn reward points at our store, and more!  
    TalkBass.com has been uniting the low end since 1998.  Join us! :)

Question about writing VBA in Excel

Discussion in 'Off Topic [BG]' started by LiquidMidnight, Apr 14, 2006.

  1. LiquidMidnight


    Dec 25, 2000

    I'm trying to perform a task here, and I was wondering if anyone could steer me in the right direction. I'm trying to copy information from one sheet to another (the source varies from A3 to A3:A16). The thing is that I don't want to overwrite previously copied information, and I want the new copy to begin directly after the old copy. My code is currently

    Sub Move()

    Dim i As Integer

    i = 1

    Range("A3:A16").Copy _
    Destination:=Sheets("sheet2").Range("A" & i)

    i = i + 1

    End Sub

    I've tried the "For each workrow..." command, but it just copies one of my pieces of information a bazillion times. Also, I want the destination to begin in cell A2, but when I type that in, it doesn't post at all.

    Any help would greatly be appreciated. :)
  2. SuperDuck


    Sep 26, 2000
    Man, it's been a while since I've done any VB. There might be a simpler way, but you can write an If-Then where it looks to see if a cell has a value, and if it does it will move to the next one down, and if it doesn't it will add the data.

    The way you have it written, it looks like the first time you run your sub routine it will send your data to A1, and then the next time A2, and then A3, etc.
  3. LiquidMidnight


    Dec 25, 2000
    Cool, I never thought of trying an If-And statement. I think that might be the best COA in this situation.

    Thank you. :)
  4. SuperDuck


    Sep 26, 2000
    Cool! Hopefully that will work out.

Share This Page