LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Verify Data Format via VB

Hi Mike,

Here is some code to get you started

Sub Check()
Dim i As Long

For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "A").Value < "" Then
If Not IsNumeric(Cells(i, "A").Value) Then
Cells(i, "A").Interior.ColorIndex = 3
End If
End If
Next i

For i = 1 To Cells(Rows.Count, "B").End(xlUp).Row
If Cells(i, "B").Value < "" Then
If Not IsDate(Cells(i, "B").Value) Then
Cells(i, "B").Interior.ColorIndex = 3
End If
End If
Next i

For i = 1 To Cells(Rows.Count, "C").End(xlUp).Row
If Cells(i, "C").Value < "" Then
If IsNumeric(Cells(i, "B").Value) Then
Cells(i, "C").Interior.ColorIndex = 3
End If
End If
Next i

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mike" wrote in message
...
Hi all.

Searched for this with no joy. I have a worksheet with data in columns

that are either dates, numbers or free text. The worksheet is processed by a
second application which doesn't run any syntax checks, so i am trying to
implement a syntax check myself (it is possible ot generate this data
worksheet this data in the wrong columns).
Thus, i am trying to create a VB macro that will check, for example, that

all entries in column A are numbers, all entries in column B are dates etc
etc.
Not getting much joy googl'ing it either.
TIA

Mike



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot verify XNPV with PV or HP-12C ncw Excel Worksheet Functions 4 May 9th 09 12:35 AM
How to verify selected data from drop-down list? PG Excel Worksheet Functions 1 September 5th 08 03:43 PM
How can I check/verify data in my Data Source for Pivot table? gayleh Excel Worksheet Functions 1 April 16th 08 08:30 PM
verify data with macro? Elizabeth New Users to Excel 1 November 16th 06 09:29 PM
Several Dates -Verify zeek Excel Worksheet Functions 4 January 16th 05 01:31 PM


All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"