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
Bookmarks