Results 1 to 6 of 6

Numbers not recognized as such

Threaded View

  1. #1
    Registered User
    Join Date
    10-01-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2013
    Posts
    7

    Numbers not recognized as such

    Hello

    Here is my macro.. It processes data from a .csv imported.
    I managed to get the data I need from one sheet to the other. Now I would like to eliminate some rows (where the value of the transaction is positive).
    However, it looks like the values in the range "transactions" (and thus cell) are not recognized as numbers.
    Checking if they are positive (cell >= 0) gives a type error, and indeed it the "IsNumeric" gives a false (and the TypeName gives back a variant).
    The numbers are formatted something like -123,45, but I also tried using plain integers (1, 10, 100) and they are still not recognized as numeric.

    What is the problem?

    Private Sub CommandButton2_Click()
    'Create a new sheet named as the considered month
    Dim newsheet
    Set newsheet = Sheets.Add(After:=Sheets(Worksheets.Count))
    newsheet.Name = MonthName((Month(Now) - 1)) & " " & Year(Now)
    
    'Copies the content to the new sheet
    ActiveSheet.Range("A1:C3").Value = Worksheets(1).Range("A1:C3").Value
    ActiveSheet.Range("A2").Select
    ActiveSheet.Paste
    
    'Takes away the rows with positive transactions
    Dim transactions As Range
    Set transactions = Selection.Columns(3)
    transactions.Select
    transactions.NumberFormat = "0.00"
    For Each cell In transactions
    cell.Select
    If IsNumeric(cell.Value) Then ' <---    Here is the problem!
    MsgBox "whatever"
    Else
    MsgBox TypeName(cell.Value)
    'cell.EntireRow.Delete
    transactions.Select
    End If
    Next
    Last edited by d_abbatelli; 07-01-2014 at 08:53 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 07-10-2013, 09:45 PM
  2. [SOLVED] Numbers in cells not recognized when using InputBox to copy and paste rows
    By Nikolette in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-25-2013, 07:09 PM
  3. Data from Access to Excel (numbers not recognized)
    By excelcool in forum Excel General
    Replies: 0
    Last Post: 02-02-2011, 05:06 PM
  4. Value not recognized as value
    By Roadie in forum Excel General
    Replies: 2
    Last Post: 04-20-2005, 02:54 AM
  5. [SOLVED] Decimal numbers not recognized as numbers
    By Stein Kristiansen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-13-2005, 06:06 PM

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