+ Reply to Thread
Results 1 to 5 of 5

Need help with Macro to do F2

  1. #1
    Registered User
    Join Date
    02-18-2005
    Posts
    93

    Unhappy Need help with Macro to do F2

    I am trying to do an upload into a company database and the formatting has to be perfect. Unfortunately one of my fields contains a number that has to be converted into text. This was simple enough but now I have to click on every cell and "F2". This causes no visible change in the cell and my spreadsheet is 6000 lines long. I would like to do this with a macro.
    When I recorded the Macro the code reads Formula.R1C1 = "107231"
    where the number has been enclosed in Apostrophies.
    I want the numbers in this column to stay text, and stay the same.
    How can I write the code to do this?
    So Far I have
    Range "J"
    Formula.r1c1 = " " which wiped out my entire column.
    Help!
    Deb

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Deb,

    What you have encountered with the number being a string is a standard practice with most flat and CSV file conventions. The macro would need to search your file either by checking all cells for numbers (if the number is not always in specific field) or by checking the field or fields you know the number wills always be in. Another important piece of information is what are maximum number of rows and columns being used?. Knowing this information will help greatly in creating an efficient macro for you. Please let me know.

    Thanks,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-18-2005
    Posts
    93
    The column containing the number will also contain letters in some cases.
    The maximum number of columns is 14, (a-n) the rows are 6000.
    I will not do it all in one upload as there are other tasks I need to perform on some of the cells.
    Deb

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Deb,

    Maybe I missed something. If some of the numbers also contain letters, wouldn't that be a string? The macro will convert "12345" into the number 12345. If it contains letters like "12A 345", "123 45A" then I need to know if a number is to extracted from the string and what the formatting looks like.

    Thanks again,
    Leith Ross

  5. #5
    Registered User
    Join Date
    02-18-2005
    Posts
    93
    Thanks,
    But we have been thrashing this thing around and came up with this
    Sub Scotty()
    '
    ' Scotty Macro
    ' Macro recorded 2/18/2005 by Food Sector
    '
    Dim ScottString As String

    For i = 148 To 325
    ScottCell = "J" & Trim(Str(i))
    'Debug.Print ScottCell
    Range(ScottCell).Select
    ScottString = Cells(i, 10)
    Cells(i, 10) = ScottString

    'Debug.Print ScottString

    Next i
    You probaly understand it better than I do, but the important thing is that my uploads work, and I can get on with the uploads versus the stupid work of using F2 on every cell.
    Thanks again for your help. This is my first visit to your website and I am very excited about the opportunities being talked about here.
    Deb

+ 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