How to check a cell for content before running macro.

G

Guest

I have some raw data that is not delimited. I want to use a macro to delimit
it and then remove a column.
I have recorded a macro to do this:
Sub delimit_raw_data()
'
' delimit_raw_data Macro
' Macro recorded 7/10/2005 by Incoherent
'

'
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=True,
FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), Array(6, 1), Array(7 _
, 1), Array(8, 1))
Range("A27").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlToLeft
Range("E24").Select
End Sub

What I need to happen is for the macro to check one of the cells to see if
there is data there, if there is, DO NOT run the rest of the macro and put up
a message saying "data already delimited you idiot, quitting" or something
similar.
I am VB imbecile.

Thanks

Incoherent
 
T

Tom Ogilvy

Sub delimit_raw_data()
'
' delimit_raw_data Macro
' Macro recorded 7/10/2005 by Incoherent
'

'
If not isempty(Range("B9")) then
msgbox "Data already delimited, hit key to quit",vbOk
exit Sub
End if
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited,
_
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True,
_
Semicolon:=False, Comma:=False, Space:=True, Other:=True,
FieldInfo:= _
Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), Array(6, 1), Array(7 _
, 1), Array(8, 1))
Range("A27").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlToLeft
Range("E24").Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top