+ Reply to Thread
Results 1 to 26 of 26

I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automatica

  1. #1
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automatica

    I have a workbook that has almost 1500 worksheets. Each worksheet is not set up as a table. Some cells may contain data or text. I am needing to pull specific cells in all worksheets into one worksheet. Doing this will allow me to create a table with the data that I want. If the workbook was smaller I could simply use a formula to return a cell, but I can't do this for nearly 1500 sheets.



    Can someone write me a script that will allow me to pull the data/text in a specific cell in all (almost 1500 worksheet) worksheets. I was hoping if someone did at least one, I could copy and paste or figure out how to duplicate that script to all the other cells I need.



    In case you need this information. The cells that I am needing are as follows:

    A12, A13, A14, A15, A16, A17, A18, A19, A20

    B5, B6, B7, B8, B9, B12, B13, B14, B15, B16, B17, B18, B19, B20

    F6, F7, F8, F9, F10

    J6, J7, J8, J9, J10
    Last edited by Mizzou.2018; 09-09-2018 at 08:01 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Hi, and welcome to the forum.

    Here's one approach
    First list all the sheet names in column A of the Consolidation sheet using the following macro.

    Please Login or Register  to view this content.
    The enter the cell references on row 1 starting in B1. e.g. A12, A13

    Then in B2 copied across and down all 1500 rows
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See attached
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    I appreciate your reply, but unfortunately I'm new to this and wasn't able to duplicate your results. Any more instructions or help would be appreciated. I have included a document for same. This is the same file as what I'm working with. The only changes I made were to private information and reduced worksheets from nearly 1500 to 3.
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Try this:

    Please Login or Register  to view this content.
    The test book:
    Attached Files Attached Files
    Last edited by xladept; 09-09-2018 at 07:48 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    That WORKED!!!!!!! Thank you so much!

    Now, I also need to return the survey question with its response. I also need to return A12, A13, A14, A15, A16, A17, A18, A19, A20, B12, B13, B14, B15, B16, B17, B18, B19, B20. These will be in the same row as the above data did. Doing this will allow the entire survey(sheet) to be returned to one row.

    The catch to this... Not every survey have all the questions answered. Some individuals skipped the question which means the 4th question on one person survey may not be the 4th question on another survey. I would need the the question returned in one cell in the row and the questions answer in the next cell in that same row (question, response).

    Is there a some kind of "IF" statement saying if a cell says "Provider explained things in a way that was easy to understand" then return the response to column "M", if not then leave blank.

    I've updated the example so you can see what I'm wanting for the responses. Once it's all done, I will want to split the text and data from the cells-- see the tab "final product".
    Attached Files Attached Files
    Last edited by Mizzou.2018; 09-09-2018 at 08:25 PM.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 09-10-2018 at 02:24 PM.

  7. #7
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Thank you! You have no idea how much help you are. I really appreciate it.

    This new script took care of the problem of having the data in the same cell as the text. It now only returns the data that I want, which is great!

    I am still needing the survey questions and question responses. Not every survey have all the questions answered. Some individuals skipped the question which means the 4th question on one person survey may not be the 4th question on another survey. I would need the the question returned in one cell in the row and the questions answer in the next cell in that same row (question, response).

    Is there a some kind of "IF" statement saying if a cell says "Provider explained things in a way that was easy to understand" then return the response to column "M", if not then leave blank.

    The tab "final product" shows how I would like the questions as column headers and the responses in cells below. I just need to make sure the responses are to that question. You can see in the example that there are two questions that were not answered so the responses/ cells are blank.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Is there a some kind of "IF" statement saying if a cell says "Provider explained things in a way that was easy to understand" then return the response to column "M", if not then leave blank.
    With this code we check the headers for an entry (anywhere in column A) and if a match is found, enter it

    Please Login or Register  to view this content.
    And, you're welcome

  9. #9
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Rule 03: Cross-posting Without Telling Us

    Your post does not comply with Rule 3 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.
    Please familiarise yourself with the rules before posting. You can find them here.

  10. #10
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Oh I see. Yeah I wasn't testing these with headers, but now that I have them it works great!

    There are two columns that are not returning
    1. The date the survey was returned (cell F8) is not returning but the column is empty.
    2. There are up to three options for a Diagnosis code (cell F9), but only two are returning. Some may only have 1, some may have 2 and some may have 3. This column is also returning blank.

    Would these be easy fixes?

  11. #11
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Mizzou.2018

    Please read my response in post 9 then do as I have asked, and I will restore your last post.

    DominicB

  12. #12
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    I posted this question in another forum- MrExcel.
    Last edited by Mizzou.2018; 09-10-2018 at 05:27 PM.

  13. #13
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    This question has been asked on Mrexcel as well.

  14. #14
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Quote Originally Posted by Mizzou.2018 View Post
    I appreciate your reply, but unfortunately I'm new to this and wasn't able to duplicate your results. Any more instructions or help would be appreciated. I have included a document for same. This is the same file as what I'm working with. The only changes I made were to private information and reduced worksheets from nearly 1500 to 3.
    We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned. It's therefore important to show us exactly what your workbook looks like.

    You didn't tell us for instance that one cell contains up to three names which need to split into three cells on the summary. You also use merged cells which is generally not a good idea and should be avoided.

    I'm attaching the INDIRECT solution. You'll need to adapt it slightly and use string slicing functions to split the column B text cells into three separate word cells.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Xladept, Thank you!!! I didn't have the headers correctly so it didn't work correctly at first. I have the headers and it now works GREAT!!!



    There are two columns that are not returning anything.

    Column I- Survey Return Date
    Column N- Diagnosis Code

    Can you tweak this code?

  16. #16
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Xladept, Thank you!!! I didn't have the headers correctly so it didn't work correctly at first. I have the headers and it now works GREAT!!!



    There are two columns that are not returning anything.

    Column I- Survey Return Date
    Column N- Diagnosis Code

    Can you tweak this code?

  17. #17
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Your sample has no results in Column N but Column I is now included:

    Please Login or Register  to view this content.
    Last edited by xladept; 09-10-2018 at 11:11 PM. Reason: Housekeeping

  18. #18
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Sheet 2 (29108447), Cell F9 "Diagnosis Codes: M76.31, Z96.651, Z96.652". There are three Diagnosis codes. The first "M76.31" returns in column L, the second "Z96.651" returns in column M, and the third "Z96.652" needs to return in column N.

    See new attachment
    Attached Files Attached Files

  19. #19
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Altered code worked on your sample:

    Please Login or Register  to view this content.

  20. #20
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Altered code worked on your sample:

    Please Login or Register  to view this content.
    *And, thanks for the compliment and for the rep!

  21. #21
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    You're very welcome. I really do appreciate your help. This has been HUGE. I've been manually typing these surveys into excel so this is 10000x easier. And I can save for future surveys.

    My last question... I've updated the example (see attachment) with comments. Depending how many questions the patient responded to the survey comments may be in different rows. I would like these returned with the other data at the very end.
    Attached Files Attached Files

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    Still some editing required - do you really need those comment text labels?

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    This is perfect for the comments! Thank you!


    I received 3 other files with over 900 (surveys) worksheets on each. On one of the files the worksheet names are differently this time. They are named as follows (page1, page1_2, page1_3, etc). The other two files have the same style worksheet names. I attempted to copy and paste this code into those files. I did make sure to name the data sheet as "Ideal Table", but it didn't return anything.

    Is there a way for be to be able to copy and paste the code into different files?


    My hope is to paste this code into all three files, create 3 big tables, then copy and paste those tables into one massive excel table. I will then begin analysis to be able to come up with feedback for the doctors.


    Just so you know what I will be doing with them, I've attached an example. DO NOT feel obligated to do anything, but if you have any recommendations I'd love to hear. In Row 1 there are definitions of what the columns are for. There are worksheets with tables of what I will be looking at. My ultimate goal is to be able to give the doctors feedback on their strong areas and areas of opportunity.
    Attached Files Attached Files

  24. #24
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    If it's every sheet but Ideal Table then this will run:

    Please Login or Register  to view this content.

  25. #25
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    You rock, thank you!

    I have copied the table into a new workbook and created a table. I am now needing to de-identify the visit number (column E) and MRN (column G) and place the new de-identified number in the following column (column F and H). I have already removed duplicates so I don't have to worry about duplicate visit numbers, so there will only be one of its kind. MRN's however, may have multiple entries depending if they submitted multiple surveys and I want to keep the duplicated MRN, I just want the numbers changed. All numbers will need to be changed. Duplicates need to stay duplicated just a changed/de identified.



    How can I quickly change the visit numbers (currently 8 digits) to a random number (6 digits or anything other than 8 digits)?

    How can I quickly change the MRN's (currently 9 digits) to a random number (8 digits or anything other than 9 digits) and still have the MRN's stay duplicated when that person submitted more than one surveys?

    See attachment.
    Attached Files Attached Files
    Last edited by Mizzou.2018; 09-23-2018 at 11:44 PM.

  26. #26
    Registered User
    Join Date
    09-09-2018
    Location
    Missouri, USA
    MS-Off Ver
    Microsoft for Mac, Version 16.16.1, Office 365
    Posts
    37

    Re: I need a VBA script that will allow me to reference a cell(s) in ALL worksheets automa

    @xladept,

    xladept

    Because you're a genius, I'm posting my two new questions here. Maybe you could help.


    https://www.excelforum.com/excel-pro...ml#post4980855

    https://www.excelforum.com/excel-pro...ml#post4980852
    Last edited by Mizzou.2018; 09-26-2018 at 01:06 PM.

+ 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. [SOLVED] How to link worksheets so editing one will edit others automatica
    By jax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  2. Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  3. Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  4. [SOLVED] How to link worksheets so editing one will edit others automatica
    By jax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. How to link worksheets so editing one will edit others automatica
    By jax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. [SOLVED] How to link worksheets so editing one will edit others automatica
    By jax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. How to link worksheets so editing one will edit others automatica
    By jax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  8. How to link worksheets so editing one will edit others automatica
    By jax in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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