ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Number Value Check Question (https://www.excelbanter.com/excel-programming/403069-number-value-check-question.html)

Kim

Number Value Check Question
 
Hi, I think this is a quick one:

I have a whole column of values that are formatted as "Date" but some of the
values are actual dates, while some are text. I want to cut and move the text
values and ignore the real dates, but the code below isn't working to pick
out the numbers vs. text.

If ActiveCell Like "#%" Then
ActiveCell.Offset(1, 0).Activate
Else
ActiveCell.Select
Selection.Cut
ActiveCell.Offset(-1, 1).Activate
ActiveSheet.Paste
ActiveCell.Offset(1, -1).Activate
End If

---Thanks!

Dan R.

Number Value Check Question
 
Try this:

Sub test()
Dim rng As Range, lrow As Long, i As Range
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range(Cells(1, 1), Cells(lrow, 1))
For Each i In rng
If Not Application.WorksheetFunction.IsNumber(i) Then
i.Cut i.Offset(, 1)
End If
Next i
End Sub

--
Dan

On Dec 20, 11:30 am, Kim wrote:
Hi, I think this is a quick one:

I have a whole column of values that are formatted as "Date" but some of the
values are actual dates, while some are text. I want to cut and move the text
values and ignore the real dates, but the code below isn't working to pick
out the numbers vs. text.

If ActiveCell Like "#%" Then
ActiveCell.Offset(1, 0).Activate
Else
ActiveCell.Select
Selection.Cut
ActiveCell.Offset(-1, 1).Activate
ActiveSheet.Paste
ActiveCell.Offset(1, -1).Activate
End If

---Thanks!



All times are GMT +1. The time now is 03:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com