How to check a cell for content before running macro.

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top