Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:28:52+00:00 2026-06-17T09:28:52+00:00

Possible Duplicate: Using FSO to insert folder name into cell based on criteria being

  • 0

Possible Duplicate:
Using FSO to insert folder name into cell based on criteria being met

Here’s what I’m trying to do:

  • Check to see where the last cell with data is located in column “A” (works)
  • Paste the data into column “A” to wbkVer.Worksheets(“Cutsheets”) (works)
  • Find the name of the folder, which is fsoFol.Name (works)
  • For each pasted cell in “A”, check for a value.
  • If there’s a value, I need to put the fsoFol.Name in the offset(0,5)–this should be able to reference off of the firstRange variable, but per cell, and I can’t figure out how to do it –or the best way to do that. (doesn’t work)
  • if there’s no value, skip it.

Suggestions? Thank you in advance.

 Dim FSO As Object, fld As Object, Fil As Object
    Dim fsoFile As Object
    Dim fsoFol As Object

    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set fld = FSO.getfolder(folderPath)

    If FSO.folderExists(fld) Then
        For Each fsoFol In FSO.getfolder(folderPath).subfolders
            For Each fsoFile In fsoFol.Files
                If Mid(fsoFile.Name, InStrRev(fsoFile.Name, ".") + 1) = "xls" Then
    fileName = fsoFile.Name
    Application.ScreenUpdating = False
    Set wbkCS = Workbooks.Open(fsoFile.Path)

    If fileName Like "V*.xls" Then
    wbkCS.Worksheets("Cut Sheet").Range("S4:S2000").Copy
       With wbkVer.Worksheets("Cutsheets")
    Set firstRange = .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0) 
        firstRange.PasteSpecial xlPasteValues
    For Each firstRange.Value in wbkVer.Worksheets("Cutsheets")
        If firstRange.Value <> "" Then
        firstRange.Offset(0, 5).Value = fsoFol.Name
                  End If
            Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:28:52+00:00Added an answer on June 17, 2026 at 9:28 am

    Your syntax of the For Each a In b loop is wrong: b returns a collection (in this case the Cells in a Worksheet, a must be of the type of members of that collection (in this case `Range.

    So correct syntax is

    For Each firstRange in wbkVer.Worksheets("Cutsheets")
    

    That said, you really don’t want to do this. What the loop will do is check every cell on the sheet (billions!), that will be so slow. Also, it will run away, since each time it finds a non blank cell it creates another one to tigger the If.

    Update

    Based on your comment, I think what you want is:

    • For every cell you just pasted in column A that is not blank, put the value of fsoFol.Name in columnF

    If so, try this (replace from wbkCS.Worksheets("Cut Sheet").Range("S4:S2000").Copy down)

    Dim rngSource As Range
    Set rngSource = wbkCS.Worksheets("Cut Sheet").Range("S4:S2000")
    With wbkVer.Worksheets("Cutsheets")
        Set firstRange = .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0).Resize(rngSource.Rows.Count, 1)
        firstRange.Value = rngSource.Value
        firstRange.SpecialCells(xlCellTypeConstants).Offset(0, 5) = fsoFol.Name
    End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Using SendMessage to enter text into an edit control belonging to another
Possible Duplicate: Using QSlider to change the value of a variable I'm trying to
Possible Duplicate: Using an NSXMLParser to parse HTML I am trying to parse the
Possible Duplicate: Using LibTiff in Visual Studio 2010 I have been trying to work
Possible Duplicate: Using Source Control So, although even here on Stack Overflow are literally
Possible Duplicate: Using delegate() with hover()? I am trying this code, but apparently I
Possible Duplicate: Using ggplot2, can I insert a break in the axis? I'm using
Possible Duplicate: Using Git with an existing Xcode project Setting up a git repository
Possible Duplicate: Using ASP.NET Controls without databinding My previous question yielded few results so
Possible Duplicate: using bash: write bit representation of integer to file I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.