Results 1 to 8 of 8

Thread: Copy rows and column headings to new workbook based on cell value

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Mar 2017
    Posts
    32
    Location

    Copy rows and column headings to new workbook based on cell value

    Hello everyone,

    Hoping someone can help. I've got some data in a table and one of the columns (L) has a value of "Yes" or "No". I would like a code to be able to copy across columns B, C, D, E and K to a new workbook (along with the column headings) if Column L has a value of "No".

    After this I would then like to be able to split the newly copied data into separate tabs based on Column C. So for example if column C says "Property" I'd like all those that say "Property" on its own tab and I'd like this to continue across all the different categories in column C (6 different categories included).

    This far I've only managed to add a new workbook but I get a little stuck after that. I've attached a dummy file showing what the data looks like. This is the code I have so far:
    Dim wb As WorkbookDim FileName As String
    
    
    Set wb = Workbooks.Add
    Application.DisplayAlerts = False
    
    
    fileSaveName = Application.GetSaveAsFilename( _
    fileFilter:="Excel Macro-Enabled Workbook (*.xlsm), *.xlsm")
    
    
    'If user has specified file name, perform Save and display a message box
        If fileSaveName <> False Then
            ActiveWorkbook.SaveAs FileName:=fileSaveName, FileFormat:=52
        
            MsgBox "Save as " & fileSaveName
        End If
    
    
    Application.DisplayAlerts = True
    Thank you so much!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •