Move odd and even data from sheet1

Doublecork

New Member
Joined
Sep 8, 2009
Messages
25
Need help! I am trying to figure out how to have odd numbers in column A on sheet1 move onto sheet2 column A and even numbers in column A on sheet1 move onto sheet3 column A. Thanks in advance for all help.
[TABLE="width: 64"]
<tbody>[TR]
[TD]T029C
[/TD]
[/TR]
[TR]
[TD]T041D
[/TD]
[/TR]
[TR]
[TD]T043B
[/TD]
[/TR]
[TR]
[TD]T043C
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Need help! I am trying to figure out how to have odd numbers in column A on sheet1 move onto sheet2 column A and even numbers in column A on sheet1 move onto sheet3 column A. Thanks in advance for all help.
[TABLE="width: 64"]
<tbody>[TR]
[TD]T029C
[/TD]
[/TR]
[TR]
[TD]T041D
[/TD]
[/TR]
[TR]
[TD]T043B
[/TD]
[/TR]
[TR]
[TD]T043C
[/TD]
[/TR]
</tbody>[/TABLE]
Are your values always exactly one letter, three digits, one letter as shown in your examples?

The odd/even numbers are the 3-digit numbers, not the individual digits, correct?
 
Last edited:
Upvote 0
Yes the are
3-digit numbers, not the individual digits.

Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub OddsAndEvens()
  Dim R As Long, O As Long, E As Long, Data As Variant, OddEven As Variant
  Data = Sheets("Sheet1").Range("A1", Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp))
  ReDim OddEven(1 To UBound(Data), 1 To 2)
  For R = 1 To UBound(Data)
    If Mid(Data(R, 1), 4, 1) Mod 2 Then
      O = O + 1
      OddEven(O, 1) = Data(R, 1)
    Else
      E = E + 1
      OddEven(E, 2) = Data(R, 1)
    End If
  Next
  Sheets("Sheet2").Range("A1").Resize(UBound(OddEven), 2) = OddEven
End Sub[/td]
[/tr]
[/table]

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (OddsAndEvens) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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