+ Reply to Thread
Results 1 to 10 of 10

macro only run if cell is not empty

  1. #1
    Pieter
    Guest

    macro only run if cell is not empty

    i have a macro thats copy a row to a worksheet. To make it perfect i want
    that the macro looks if for example Cell A 5 in that row is not empty. If its
    not empty run de macro thats copy the row to a worksheet. If its not empty
    that the user got an error windows for example: A5 is empty Macro do not work.

    is this possible...?

    greetings.



  2. #2
    R.VENKATARAMAN
    Guest

    Re: macro only run if cell is not empty



    try this

    Public Sub test()
    If Range("A5") <> "" Then
    (macro name)
    Else
    MsgBox "A5 is empty Macro does not work."


    End If
    End Sub

    "Pieter" <[email protected]> wrote in message
    news:[email protected]...
    > i have a macro thats copy a row to a worksheet. To make it perfect i want
    > that the macro looks if for example Cell A 5 in that row is not empty. If

    its
    > not empty run de macro thats copy the row to a worksheet. If its not empty
    > that the user got an error windows for example: A5 is empty Macro do not

    work.
    >
    > is this possible...?
    >
    > greetings.
    >
    >




  3. #3
    Stefi
    Guest

    RE: macro only run if cell is not empty

    If Range("A5") = Empty Then
    MsgBox "Cell A5 is empty!"
    Else
    Call copymacro_name
    End If


    Regards,
    Stefi

    „Pieter” ezt *rta:

    > i have a macro thats copy a row to a worksheet. To make it perfect i want
    > that the macro looks if for example Cell A 5 in that row is not empty. If its
    > not empty run de macro thats copy the row to a worksheet. If its not empty
    > that the user got an error windows for example: A5 is empty Macro do not work.
    >
    > is this possible...?
    >
    > greetings.
    >
    >


  4. #4
    Pieter
    Guest

    RE: macro only run if cell is not empty

    thanks for the quick response but
    this is only working when cell A5 is empty.
    it must also work when i want to run de macro on row 150 for example.
    so then A 150 the macro had to check if its empty or not.

    gr.

    "Stefi" wrote:

    > If Range("A5") = Empty Then
    > MsgBox "Cell A5 is empty!"
    > Else
    > Call copymacro_name
    > End If
    >
    >
    > Regards,
    > Stefi
    >
    > „Pieter” ezt *rta:
    >
    > > i have a macro thats copy a row to a worksheet. To make it perfect i want
    > > that the macro looks if for example Cell A 5 in that row is not empty. If its
    > > not empty run de macro thats copy the row to a worksheet. If its not empty
    > > that the user got an error windows for example: A5 is empty Macro do not work.
    > >
    > > is this possible...?
    > >
    > > greetings.
    > >
    > >


  5. #5
    Stefi
    Guest

    RE: macro only run if cell is not empty

    If Range("A" & ActiveCell.Row) = Empty Then
    MsgBox "Cell A5 is empty!"
    Else
    Call copymacro_name
    End If

    Regards,
    Stefi

    „Pieter” ezt *rta:

    > thanks for the quick response but
    > this is only working when cell A5 is empty.
    > it must also work when i want to run de macro on row 150 for example.
    > so then A 150 the macro had to check if its empty or not.
    >
    > gr.
    >
    > "Stefi" wrote:
    >
    > > If Range("A5") = Empty Then
    > > MsgBox "Cell A5 is empty!"
    > > Else
    > > Call copymacro_name
    > > End If
    > >
    > >
    > > Regards,
    > > Stefi
    > >
    > > „Pieter” ezt *rta:
    > >
    > > > i have a macro thats copy a row to a worksheet. To make it perfect i want
    > > > that the macro looks if for example Cell A 5 in that row is not empty. If its
    > > > not empty run de macro thats copy the row to a worksheet. If its not empty
    > > > that the user got an error windows for example: A5 is empty Macro do not work.
    > > >
    > > > is this possible...?
    > > >
    > > > greetings.
    > > >
    > > >


  6. #6
    Pieter
    Guest

    RE: macro only run if cell is not empty

    Perfect this is exactly what i want...

    thanks

    "Stefi" wrote:

    > If Range("A" & ActiveCell.Row) = Empty Then
    > MsgBox "Cell A5 is empty!"
    > Else
    > Call copymacro_name
    > End If
    >
    > Regards,
    > Stefi
    >
    > „Pieter” ezt *rta:
    >
    > > thanks for the quick response but
    > > this is only working when cell A5 is empty.
    > > it must also work when i want to run de macro on row 150 for example.
    > > so then A 150 the macro had to check if its empty or not.
    > >
    > > gr.
    > >
    > > "Stefi" wrote:
    > >
    > > > If Range("A5") = Empty Then
    > > > MsgBox "Cell A5 is empty!"
    > > > Else
    > > > Call copymacro_name
    > > > End If
    > > >
    > > >
    > > > Regards,
    > > > Stefi
    > > >
    > > > „Pieter” ezt *rta:
    > > >
    > > > > i have a macro thats copy a row to a worksheet. To make it perfect i want
    > > > > that the macro looks if for example Cell A 5 in that row is not empty. If its
    > > > > not empty run de macro thats copy the row to a worksheet. If its not empty
    > > > > that the user got an error windows for example: A5 is empty Macro do not work.
    > > > >
    > > > > is this possible...?
    > > > >
    > > > > greetings.
    > > > >
    > > > >


  7. #7
    Stefi
    Guest

    RE: macro only run if cell is not empty

    You are welcome! Thanks for the feedback!
    Regards,
    Stefi


    „Pieter” ezt *rta:

    > Perfect this is exactly what i want...
    >
    > thanks
    >
    > "Stefi" wrote:
    >
    > > If Range("A" & ActiveCell.Row) = Empty Then
    > > MsgBox "Cell A5 is empty!"
    > > Else
    > > Call copymacro_name
    > > End If
    > >
    > > Regards,
    > > Stefi
    > >
    > > „Pieter” ezt *rta:
    > >
    > > > thanks for the quick response but
    > > > this is only working when cell A5 is empty.
    > > > it must also work when i want to run de macro on row 150 for example.
    > > > so then A 150 the macro had to check if its empty or not.
    > > >
    > > > gr.
    > > >
    > > > "Stefi" wrote:
    > > >
    > > > > If Range("A5") = Empty Then
    > > > > MsgBox "Cell A5 is empty!"
    > > > > Else
    > > > > Call copymacro_name
    > > > > End If
    > > > >
    > > > >
    > > > > Regards,
    > > > > Stefi
    > > > >
    > > > > „Pieter” ezt *rta:
    > > > >
    > > > > > i have a macro thats copy a row to a worksheet. To make it perfect i want
    > > > > > that the macro looks if for example Cell A 5 in that row is not empty. If its
    > > > > > not empty run de macro thats copy the row to a worksheet. If its not empty
    > > > > > that the user got an error windows for example: A5 is empty Macro do not work.
    > > > > >
    > > > > > is this possible...?
    > > > > >
    > > > > > greetings.
    > > > > >
    > > > > >


  8. #8
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: macro only run if cell is not empty

    Hi, a newcomer here trying to get to grips with Macros so thanks in advance of any help.

    The above solution is good as it looks through the whole named column (e.g. A) for cells that are not empty. But when I test it this seems to also include the first cell which is part of my data header across the whole first row. Is there any way to skip that?

    Also what I want to do is once I find a cell with something in it I wish to create a blank row below it e.g. If something is found row 3 in Cell C create a new row so row 4 is blank.
    Then repeat until I reach the end of the file.

    Is this possible?

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: macro only run if cell is not empty

    Hi, AS147,

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  10. #10
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: macro only run if cell is not empty

    Understood, thanks for the advice

+ 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