+ Reply to Thread
Results 1 to 2 of 2

VBA Copy each columns to new sheet and rename based on column value

  1. #1
    Registered User
    Join Date
    12-15-2020
    Location
    U.S.
    MS-Off Ver
    2016/Office 365
    Posts
    5

    VBA Copy each columns to new sheet and rename based on column value

    Hi All,

    I am a total VBA noob and I have the following code I found below and this would be what I'm trying to accomplish:
    1. Export all individual columns (Column B and active columns) with data into new sheets
    2. Keep the titles in Column A of the primary worksheet in each new sheet
    3. Rename the sheets based on Columns B4, C4, D5 etc. which contain each employees email address
    4. Last step: Send an individual email with each users slice of data from each sheet in PDF format based on the email name


    Sub t2()
    Dim lc As Long, sh As Worksheet, newSh
    Set sh = ActiveSheet
    With sh
    lc = .Cells.Find("*", , xlValues, xlPart, xlByColumns, xlPrevious).Column
    For i = 2 To lc
    If Application.CountA(.Columns(i)) > 0 Then
    Set newSh = Sheets.Add
    Intersect(.UsedRange, .Columns(i)).Copy newSh.Range("A1")
    End If
    Next
    End With
    ThisWorkbook.Save
    End Sub

    Any assistance is greatly appreciated!

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA Copy each columns to new sheet and rename based on column value

    It would be helpful if you could provide your actual file as per the yellow banner above. We can't help without the file structure.

+ 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. Replies: 1
    Last Post: 12-20-2019, 01:49 AM
  2. Replies: 9
    Last Post: 03-28-2017, 08:30 PM
  3. [SOLVED] Copy Template Sheet and rename the new sheets based on a list in another sheet
    By SaadKiji in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2016, 11:47 AM
  4. Copy columns from one sheet to new, rename headlines
    By Excelsemi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2014, 07:50 AM
  5. Replies: 0
    Last Post: 06-28-2014, 02:26 PM
  6. Create A Copy To A New Sheet & Rename Sheet Based on Cell Value
    By delicard in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-25-2013, 08:56 PM
  7. [SOLVED] Copy a sheet (from template) to a new sheet, and rename (based on cell value)
    By Siglen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2012, 10:19 AM

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