+ Reply to Thread
Results 1 to 18 of 18

VBA to autofill column across worksheets. Worksheets have dynamic table range

  1. #1
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    VBA to autofill column across worksheets. Worksheets have dynamic table range

    Hello All,
    I have a table in each worksheet in a file. Each worksheet has a dynamic table range. I want to copy a value adjacent to the beginning of the table (not included in coding) and auto fill that value down to the bottom of each table (coding below). For some reason my coding works for individual worksheets but not across all worksheets. Please advise.

    Column B Column C
    EA1.1 Step 1
    Step 2
    Step 3
    Step 4
    Step 5


    Sub Test2()
    Application.EnableEvents = False 'turn events off!
    Dim ws As Worksheet
    For Each ws In Worksheets
    If ws.Name <> "By_ProcessID" Then
    ws.Range("B33").Select
    Selection.AutoFill Destination:=ws.Range("B33:B" & Range("B1000000").End(xlUp).Row), Type:=xlFillCopy
    End If
    Next ws
    Application.EnableEvents = True 'turn events back on - this is critical, otherwise no events will fire again

    End Sub

  2. #2
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    If this code works for one sheet it should work for them all

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    I should clarify, it works on individual sheets without the IF statements

  4. #4
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Selection.AutoFill Destination:=ws.Range("B33:B" & Range("C1000000").End(xlUp).Row), Type:=xlFillCopy <- This was corrected. now it works on the first sheet, but will not continue to cycle through all sheets

  5. #5
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Please Login or Register  to view this content.
    Last edited by GaidenFocus; 07-24-2013 at 04:09 PM.

  6. #6
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Although I don't see where you are getting the value from?

  7. #7
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    You would need to include the reference value in the loop if you want it to work across all pages

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    The value is pasted to cell B33 in another macro, which works fine. I was going to combine the two as soon the autofill beings to work across all sheets
    It's not accepting your change: 'Selection.AutoFill Destination:=ws.Range(ws.Range("B33"), ws.Range("B33").End(xlDown)), Type:=xlFillCopy'

  10. #10
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Yea i would need to see the whole code to get it to work properly or a sample workbook!

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Or
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    The reference value is not being included when I input 'ws.Range("B33").Select' ?

    I apologize, my experience with VBA is somewhat limited

  13. #13
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    THANKS AB33! Worked like a charm!

  14. #14
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    actually try this

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    you would want the last row in column C correct?

  16. #16
    Registered User
    Join Date
    07-22-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    It's working, but can anyone see a reason why it clears data on the ProcessID tab when I am telling it not to:

    Please Login or Register  to view this content.
    Last edited by Kahmed2R; 07-30-2013 at 10:02 AM. Reason: updated code tags

  17. #17
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    Kahmed,
    This is for second time you have not used code tags with your code as per forum's rule. Please edit the above code and put it in code tags.

  18. #18
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: VBA to autofill column across worksheets. Worksheets have dynamic table range

    because you specified UCase for the ws.Name and compared it to a string that has lowercase. try

    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. Autofill Formula down a Column across multiple worksheets
    By Rikkdh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2013, 09:00 AM
  2. [SOLVED] Dynamic range calculations on other worksheets
    By dotsofcolor in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-09-2012, 01:45 AM
  3. Autofill using Dynamic Range (Last Column) and Last Row
    By goldenr2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2011, 11:21 PM
  4. wall stickers on worksheets based on a dynamic table
    By Jonnykanon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2011, 03:31 AM
  5. To link worksheets with dynamic range
    By mingali in forum Excel General
    Replies: 5
    Last Post: 08-10-2009, 12:02 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