+ Reply to Thread
Results 1 to 2 of 2

macro to workbook not working

  1. #1
    Registered User
    Join Date
    11-28-2022
    Location
    england
    MS-Off Ver
    365
    Posts
    28

    macro to workbook not working

    hi all, i got a macro to split my data into separate sheets from using column F but it doesn't work. it stops working when it gets to - Sheets("orderbook").Select

    what could be causing the issue?

    the macro is below.



    Sub split_data()

    Dim wb As Workbook
    Dim ws As Worksheet


    Sheets("orderbook").Select
    ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("F:F").Copy
    Sheets.Add(after:=Sheets("orderbook")).Name = "temp"
    ActiveSheet.Range("A1").PasteSpecial
    ActiveSheet.Range("A:A").RemoveDuplicates Columns:=1, Header:=xlNo
    vrw = ActiveSheet.Range("A1").End(xlDown).Row

    For i = 2 To vrw

    Sheets("temp").Select
    supplier_name = ActiveSheet.Range(a & i).Value
    Sheets("orderbook").Select
    ActiveSheet.AutoFilterMode = False


    vrw1 = ActiveSheet.Range("a1").End(xlDown).Row
    vadd = ActiveSheet.Range("a1").End(xlToRight).Address(, False)
    Vcol = Left(vadd, InStr(1, vadd, "$") - 1)

    ActiveSheet.Range("a1:" & Vcol & vrw1).AutoFilter field:=6, criterial:=supplier

    Vrw2 = activsheet.Range("a1").End(xlDown).Row

    ActiveSheet.Range("A1:" & Vcol & Vrw2).Copy

    Sheets.Add(after:=Sheets("temp")).Name = supplier_name
    ActiveSheet.Range("a1").pastesprecial xlPasteAll

    Selection.Columns.AutoFit

    Next i

    Sheets("temp").Delete

    End Sub

  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
    48,427

    Re: macro to workbook not working

    it stops working when it gets to - Sheets("orderbook").Select
    How? In what way? An error message? Code highlighted? Which Sheets("orderbook").Select line? If it is the first one, it hasn't got very far.
    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


+ 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. Workbook macro's not working when protected
    By ~TaC~ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2019, 04:31 PM
  2. Copied working macro to new workbook, but no longer working
    By twisted31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2017, 06:17 PM
  3. Macro to paste formatting only Excel 2013 - not working from workbook to workbook
    By LindyParsnips in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2016, 08:32 AM
  4. Converting workbook with Macro to a template causes the Macro to stop working
    By Skeeta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 02:00 PM
  5. Macro working in one workbook, but not another
    By phil3061 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-10-2012, 10:05 AM
  6. Macro to protect workbook not working
    By Crüe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2011, 03:50 AM
  7. Macro in excel workbook not working.
    By srikanth_bgl in forum Excel General
    Replies: 1
    Last Post: 04-27-2011, 03:09 PM

Tags for this Thread

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