+ Reply to Thread
Results 1 to 10 of 10

If text the delete, if number then copy number to another cell

  1. #1
    Registered User
    Join Date
    03-07-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    If text the delete, if number then copy number to another cell

    Hi Folks,

    I hope that you can help. I am workign on an audit tool that I need to have some form of self check built in for specific parts of the worksheets.

    I have atatched an example of what I am looking for but in brief If in Cell B2 there is a numerical value then I need cell C10 to have the value from C2, however if no numberical value then I need the cell to delete any text elements ie a space and leave the cell black.

    I have also added the actual cells from the tool (Example 2) where if any of 3 cells in a row (B25:D25) contain a numberical value then the 4th cell (E25) must contain a numberical value, otherwise the cell must be blank.

    I hope this makes any sense.

    thanks in advance.

    Copy of For James.xlsx

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If text the delete, if number then copy number to another cell

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-07-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: If text the delete, if number then copy number to another cell

    The above worked a treat, I want to try find the answer myself to my next question, how do you make the macro move down all rows to check the above. If you can tell me what I need to look for i.e. is it stepping down?? Would still appreciate the answer to this one.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If text the delete, if number then copy number to another cell

    When you say all rows, do you mean like B2-B5? Or are you talking about Example 2?

  5. #5
    Registered User
    Join Date
    03-07-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: If text the delete, if number then copy number to another cell

    HI John,

    For Example 2, I have a total of 203 rows that this check needs to run on, I have been googling all day to see how to do this.

    Thanks in advance,

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If text the delete, if number then copy number to another cell

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-07-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: If text the delete, if number then copy number to another cell

    Brilliant John, I see how that works now, however I am getting a "For without next" error, VBA opens and highlights Sub exc... in yellow and the editor also highlights End Sub.

  8. #8
    Registered User
    Join Date
    03-07-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: If text the delete, if number then copy number to another cell

    Got it, I added Next between End IF and Sub End - Again, thank you very much John.


    Sub exchangejamesA()

    Dim i As Long

    For i = 3 To 203

    If IsNumeric(Range("E" & i).Value) Or IsNumeric(Range("F" & i).Value) Or IsNumeric(Range("G" & i).Value) Then

    If Not IsNumeric(Range("H" & i).Value) Then Range("H" & i).ClearContents

    End If

    Next

    End Sub

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If text the delete, if number then copy number to another cell

    You're welcome. Glad to hear that and thanks for the feedback. Please comply with Forum Rule No. 9.

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If text the delete, if number then copy number to another cell

    You're welcome. Glad to hear that and thanks for the feedback. Please comply with Forum Rule No. 9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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