+ Reply to Thread
Results 1 to 6 of 6

Hide column in multiple files in subfolders from folder

  1. #1
    Registered User
    Join Date
    05-26-2020
    Location
    Odense, Denmark
    MS-Off Ver
    2020 - 365
    Posts
    31

    Hide column in multiple files in subfolders from folder

    Hi Forum,

    I've been searching for a VBA solution for a long time and tried multiple threads on the web, but have not been able to make a final solution... So I need help!

    I have a bigger Excel "eco system", which contains multiple worksheets in multiple workbooks.

    Initial facts:
    • The workbooks are placed in subfolders within a main folder
    • The main folder is currently placed inside a Sharepoint environment
    • The Workbooks could contain multiple sheets to be considered
      - If sheet contains date in cell D2, it should be considered
      - sheets with the name "Log" and "Instruction" should never be considered



    What I want the VBA to do:
    • An initial inputbox where to enter week number and year.
    • Find the column where week number and year matches and hide the column.
    • Proceed to next sheet if available or move further on to the next subfolder if available.
    • Some sort of error handling / error messaging. "An error occured in file X, sheet X. Would you like to proceed or stop?"
    • Possibility to use the VBA even though some of the sheets already have the matching column date hidden.
    • Final MsgBox if the VBA succeeded.



    Is there anyone out there, that have the time and VBA experience to help me with a proper solution?
    Hope my explanation make sense... I would gladly add more info if needed. I've attched a simplfied version of the "eco system" for testing.

    BR, Rasmus
    Attached Files Attached Files
    Last edited by Ralleberg; 02-03-2022 at 10:41 AM. Reason: The problem is solved

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Hide column in multiple files in subfolders from folder

    Hi Ralleberg,

    I don't have a sharpoint folder source to test on but the below works in a normal environment in regards to the folder and subfolders.

    If it finds that the column is already hidden then it will move on, as far as the error handling goes we would need to see the potential errors that could be created to be able to haandle them. The code will generally just stop if there is an error until the error is handled - it is within the handling part where you could set up an error log. Anyway I digress, I will leave the code below:

    Please Login or Register  to view this content.
    Hope this helps

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

    Re: Hide column in multiple files in subfolders from folder

    Here is another approach for you. Place code in a separate workbook not inside eco system and only run the first sub, which then runs the second sub. This only selects the week, not the year. Let us know if you have questions.

    Please Login or Register  to view this content.
    Last edited by maniacb; 01-19-2022 at 11:32 PM.

  4. #4
    Registered User
    Join Date
    05-26-2020
    Location
    Odense, Denmark
    MS-Off Ver
    2020 - 365
    Posts
    31

    Re: Hide column in multiple files in subfolders from folder

    Thank you both CheeseSandwich and maniacb.

    Both approaches did the job. Thank you so much. I've added rep for the answers.

  5. #5
    Registered User
    Join Date
    05-26-2020
    Location
    Odense, Denmark
    MS-Off Ver
    2020 - 365
    Posts
    31

    Re: Hide column in multiple files in subfolders from folder

    Quote Originally Posted by CheeseSandwich View Post
    Hi Ralleberg,

    I don't have a sharpoint folder source to test on but the below works in a normal environment in regards to the folder and subfolders.

    If it finds that the column is already hidden then it will move on, as far as the error handling goes we would need to see the potential errors that could be created to be able to haandle them. The code will generally just stop if there is an error until the error is handled - it is within the handling part where you could set up an error log. Anyway I digress, I will leave the code below:

    Please Login or Register  to view this content.
    Hope this helps
    Hi again,

    I need an addition to the code above that I need assistance with. The code looks correctly in the selected folders, but also takes .pdf and other file types into the loop, and makes quite a few corrupt files.
    the code should only take file types like .xlsm, xlsx to be taken into account within the specified folders, but how and where do I add this the code?

    Thank you in advance, Rasmus

  6. #6
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Hide column in multiple files in subfolders from folder

    Maybe one option:
    Please Login or Register  to view this content.
    If things don't change they stay the same

+ 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] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. [SOLVED] Move Files from current folder to a new subfolders specified in a column
    By zEKeBv in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-31-2020, 05:48 AM
  3. VBA Copy specific files listed in Excel from folder & subfolders to another folder - FSO
    By HelloFriends in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2019, 02:55 PM
  4. Move pdf files from multiple subfolders to a new folder
    By fabian_76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2018, 04:57 PM
  5. VBA that goes through all xls files in folder and subfolders
    By Acxer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2015, 09:06 AM
  6. [SOLVED] Combining multiple files to workbook from folder, including subfolders
    By Punssiliini in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2015, 02:38 PM
  7. Counting files in folder including subfolders also and folder size
    By mido609 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 03: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