+ Reply to Thread
Results 1 to 7 of 7

Fill Column with Workbook Name Using Wild Card

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Karachi, Sindh, Pakistan
    MS-Off Ver
    Excel 2010 - 2013
    Posts
    142

    Fill Column with Workbook Name Using Wild Card

    Hello Excel Expert,

    I found the below code in this forum and with little amendment I brought it into my work.


    Please Login or Register  to view this content.
    What I need is that it starts copying data from Column "B2" and in Column "A2" it fills the name of Workbook using wildcard. Like if the file name is
    "ABCDEFGH-XXXXXXX-XXXXXXX-DF-memory-insight". then i need it fills "ABCDEFGH" in the column A parallel with the number of records.
    If the last used row is "B2:B15" then it should fill the worksheet name using wild card from range "A2:A15".

    Can anyone help me with this!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Fill Column with Workbook Name Using Wild Card

    Try this...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 07-25-2013 at 10:15 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Karachi, Sindh, Pakistan
    MS-Off Ver
    Excel 2010 - 2013
    Posts
    142

    Re: Fill Column with Workbook Name Using Wild Card

    Dear AlphaFrog,

    Thank you for this..

    I run the macro and ran into the following problem;

    The macro start pasting the data from row number 2 along with headers. In my source file row 1 has headers,and in the master workbook i have already define the same headers according to the source file.

    I tried to change it but can't get where do i make change in it..... Can you please look into this

    And a question for my understanding how many worksheets I can maximum add into the array,[For Each ws In .Sheets(Array("Arrangment", "Request", "Status"))] as there are more worksheets' data need to be copied in the master workbook.may be around 60 worksheets from 60 workbook.


    Thanks again for your code and cooperation!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Fill Column with Workbook Name Using Wild Card

    Quote Originally Posted by Ariff_Chowdhury View Post
    Dear AlphaFrog,

    Thank you for this..

    I run the macro and ran into the following problem;

    The macro start pasting the data from row number 2 along with headers. In my source file row 1 has headers,and in the master workbook i have already define the same headers according to the source file.

    I tried to change it but can't get where do i make change in it..... Can you please look into this

    And a question for my understanding how many worksheets I can maximum add into the array,[For Each ws In .Sheets(Array("Arrangment", "Request", "Status"))] as there are more worksheets' data need to be copied in the master workbook.may be around 60 worksheets from 60 workbook.


    Thanks again for your code and cooperation!
    Change this...
    With ws.UsedRange
    To this...
    With Intersect(ws.UsedRange, ws.UsedRange.Offset(1))

    An array can have thousands of elements. It may be easier to just loop through all the worksheets in the source workbook using
    For Each ws In .Worksheets
    Then if there's a worksheet you don't want, it could be excluded with an If statement.

  5. #5
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Karachi, Sindh, Pakistan
    MS-Off Ver
    Excel 2010 - 2013
    Posts
    142

    Re: Fill Column with Workbook Name Using Wild Card

    Hello AlphaFrog,

    Many thanks again.

    I updated the code as per your instruction replacing the piece of code with provided one but got an issue.

    The macro do not copy the entire columns of source file into the master worksheet.

    What I understand in my source files there are headers but no data in it so I think (but not sure) macro taking this as an empty column and not copying the data after the column once it finds the empty columns.


    If you please have your kind consideration on this.



    Thank you so much AlphaFrog!

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Fill Column with Workbook Name Using Wild Card

    Quote Originally Posted by Ariff_Chowdhury View Post
    Hello AlphaFrog,

    Many thanks again.

    I updated the code as per your instruction replacing the piece of code with provided one but got an issue.

    The macro do not copy the entire columns of source file into the master worksheet.

    What I understand in my source files there are headers but no data in it so I think (but not sure) macro taking this as an empty column and not copying the data after the column once it finds the empty columns.


    If you please have your kind consideration on this.


    Thank you so much AlphaFrog!
    I think I understand what you are saying, but I cannot duplicate the problem. It should copy the empty columns and the data after.

    Can you post two example files; one of the Master workbook with the result data and macro code, and one source file where not all your data is copied? The data can be fake as long as it duplicates your problem.

  7. #7
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Karachi, Sindh, Pakistan
    MS-Off Ver
    Excel 2010 - 2013
    Posts
    142

    Re: Fill Column with Workbook Name Using Wild Card

    Dear AlphaFrog,

    In order to send you the example files I prepared and fills with data keeping some column entirely empty.Ran the macro to test it.

    But amazingly it copied the data after empty columns as well.I really couldn't figure out how this time macro is copying all of the data.

    In my original file I tried approx 5-6 times and every time macro were not copying the data after empty column.

    Then I again pasted the entire vba code and it ran successfully, I don't know what was going wrong at that time.I will have to keep eye on this portion because I rely on this code if anything went wrong then my all efforts will ruin.that i have previously put into it to reduce my daily laborious activities.

    I am completely new to vba but striving to read and write codes, the sample code i pasted here in my first thread, Though little bit but I understand that vba program what is the flow and what one line of code is doing. I changed and make amendment in it according to my needs....

    But unfortunately you're vba code is beyond to my head, seems advanced level of vba programming.I can hardly understand few lines your vba code.I am still trying to understand what is "UsedRange" in your vba..what it does actually......


    However, since two days, I am struggling with a line of code, and trying to find a way that how do i incoroporate the piece of code that allows me to copy data as values (pastespecial) and do not copy data with formatting...

    I know its syntax it is something like this .PasteSpecial (xlPasteValues) but don't know where it to put..


    I am working with this file in order to automate my daily hectic job.I started it with name of GOD.There are many complications in it, large data set, hundrends of files each file contains hundreds of worksheets and I want to gather all these informations in one file keeping all specific conditions and criteria in mind.So far with the help of you people it is going on as it is to be....Lets see what happens.But I would like to THANK YOU, you have been a very big help to me.

    Blessings to your home!

    Thanks again

+ 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. Wild card in Excel SQL
    By tkuia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2010, 06:36 AM
  2. use of wild card in file name.
    By avveerkar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2007, 09:27 AM
  3. Wild Card Search
    By roy.okinawa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-30-2006, 06:45 PM
  4. wild card -- help with formula
    By Michael A in forum Excel General
    Replies: 10
    Last Post: 01-08-2006, 06:20 AM
  5. Wild card *
    By Herman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-21-2005, 09:05 AM

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