+ Reply to Thread
Results 1 to 4 of 4

Troubleshoot code - Open workbooks in folder & insert 0 in cells

  1. #1
    Forum Contributor
    Join Date
    12-19-2006
    Posts
    113

    Troubleshoot code - Open workbooks in folder & insert 0 in cells

    Hi everyone,

    I'm trying to create a code to open the Sheet1 in all the workbooks in a folder, one by one, and insert an 0 in all the cells in column A that have data.

    Checking other examples, I create this:
    Please Login or Register  to view this content.
    Any help would be greatly appreciated.

  2. #2
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74
    What is the problem you are having with the code? Is it in opening the files? Saving and closing? or in putting in the 0s?

  3. #3
    Forum Contributor
    Join Date
    12-19-2006
    Posts
    113
    Hi chrismann85
    I think the problem is in insert the 0s...
    I notice that the code can open the workbooks, and insert an 0 in R1C1 of the 1st workbook open - not in the others cells, not in the other workbook I created to test the code.

    Thank you

  4. #4
    Forum Contributor
    Join Date
    12-19-2006
    Posts
    113
    Thank you to everyone who loose time try found a solution to my problem.
    I found it already:
    Replace
    Sheets("Sheet1").Select

    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Range("A1:A50").Select

    For Each cell In Selection
    If cell.Value > "" Then
    Selection.NumberFormat = "@"
    cell.Value = "0" & cell.Value
    Else
    cell.Value = ""
    End If
    Next cell

    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    with

    Sheets("Sheet1").Select

    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Worksheets("Sheet1").Columns(1).NumberFormat = "@"

    For Each c In Worksheets("Sheet1").Range("A:A").Cells

    If c.Value > "" Then c.Value = "0" & c.Value

    Next

    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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