korhan
Board Regular
- Joined
- Nov 6, 2009
- Messages
- 215
Here is what I am trying to do first I am trying figure out the value of the first occurence of a
number in a string and decide whether this number is even or odd.
It should not be this hard yet even trying to figure out the equivalent of this formula in vba is really
hard. Here is my formula for the number in the string
=MID(C2571,MAX(IF(ISERROR(FIND({1;2;3;4;5;6;7;8;9;0},C2571)),"",FIND({1;2;3;4;5;6;7;8;9;0},C2571))),1)
I did this formula in excel spreadsheet to get the number. I would like to do the same thing in VBA so I can keep everything neat in one place and run the macro as a whole.
Then i need a loop like this
Sub SortEvenandOdd()
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "ODD NUMBERS"
Sheets(1).Name = "EVEN NUMBERS"
Dim WSE As Worksheet
Set WSE = Worksheets("EVEN NUMBERS")
Dim WSO As Worksheet
Set WSO = Worksheets("ODD NUMBERS")
WSE.Range("a1:d1").Copy Destination:=Sheets("ODD NUMBERS").Range("a1")
LastRow = WSO.Cells(Rows.Count, 1).End(xlUp).Row
FinalRow = WSE.Cells(Rows.Count, 1).End(xlUp).Row
For i = FinalRow To 2 Step -1
If Cells(i, 6) Mod <> 0 Then (this is the part where I got stuck also)
Rows(i).Cut Destination:=WSO.Cells(LastRow + 1, 1)
Rows(i).Delete
On Error Resume Next
End If
Next i
End Sub
Any ideas?
number in a string and decide whether this number is even or odd.
It should not be this hard yet even trying to figure out the equivalent of this formula in vba is really
hard. Here is my formula for the number in the string
=MID(C2571,MAX(IF(ISERROR(FIND({1;2;3;4;5;6;7;8;9;0},C2571)),"",FIND({1;2;3;4;5;6;7;8;9;0},C2571))),1)
I did this formula in excel spreadsheet to get the number. I would like to do the same thing in VBA so I can keep everything neat in one place and run the macro as a whole.
Then i need a loop like this
Sub SortEvenandOdd()
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "ODD NUMBERS"
Sheets(1).Name = "EVEN NUMBERS"
Dim WSE As Worksheet
Set WSE = Worksheets("EVEN NUMBERS")
Dim WSO As Worksheet
Set WSO = Worksheets("ODD NUMBERS")
WSE.Range("a1:d1").Copy Destination:=Sheets("ODD NUMBERS").Range("a1")
LastRow = WSO.Cells(Rows.Count, 1).End(xlUp).Row
FinalRow = WSE.Cells(Rows.Count, 1).End(xlUp).Row
For i = FinalRow To 2 Step -1
If Cells(i, 6) Mod <> 0 Then (this is the part where I got stuck also)
Rows(i).Cut Destination:=WSO.Cells(LastRow + 1, 1)
Rows(i).Delete
On Error Resume Next
End If
Next i
End Sub
Any ideas?