+ Reply to Thread
Results 1 to 2 of 2

How to check a cell for content before running macro.

  1. #1
    Incoherent
    Guest

    How to check a cell for content before running macro.


    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

  2. #2
    Tom Ogilvy
    Guest

    Re: How to check a cell for content before running macro.

    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

    "Incoherent" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1