Results 1 to 3 of 3

VBA Add Column and Populate with Sheet Name

Threaded View

  1. #1
    Registered User
    Join Date
    03-07-2018
    Location
    Belfast
    MS-Off Ver
    2017
    Posts
    13

    VBA Add Column and Populate with Sheet Name

    Hi,
    Could anyone assist with some VBA which would add a Column to the beginning of a sheet, (Column A) and Populate the rows of new column with the first 8 characters of the sheet name. The file contains over 100 sheets, and we only require the first 8 characters of the sheet name to be added to the new row. The new row should only be populated for as many rows as which already contains data.

    Any help appreciated, I've found this code online, however it populates with the entire sheet name. Ideally the sheet names would also only begin to fill from Cell A3 not A1.



    Option Explicit
    
    Sub Prepare_Sheet()
    Dim WS As Worksheet
    Dim LASTROW As Long
        For Each WS In Sheets
            With WS
                LASTROW = .Range("A" & Rows.Count).End(xlUp).Row
                .Columns(1).Insert
                .Range("A1:A" & LASTROW) = WS.Name
            End With
        Next WS
    End Sub
    Any help much appreciated.

    Thanks
    Daniel
    Last edited by AliGW; 04-05-2018 at 04:12 AM. Reason: Code tags added.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Populate column from another sheet
    By miro2021 in forum Excel General
    Replies: 4
    Last Post: 09-06-2016, 12:20 PM
  2. Replies: 5
    Last Post: 09-09-2015, 09:49 AM
  3. [SOLVED] Vlookup to populate from sheet but if column is empty then use a different one?
    By kellyfirth in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-22-2015, 07:40 AM
  4. Replies: 4
    Last Post: 02-25-2014, 10:26 PM
  5. Replies: 4
    Last Post: 08-01-2013, 01:57 PM
  6. [SOLVED] Populate summary sheet with values within specific month column on data sheet...
    By blue91 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-12-2013, 12:11 PM
  7. Populate multi-column list in sheet not in UserForm
    By afzal001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2008, 12:26 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