Value in a string and then decide whether it is odd or even

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?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top