+ Reply to Thread
Results 1 to 5 of 5

VBA Code Option based on data in a cell

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    New Castle, DE
    MS-Off Ver
    Excel 2007
    Posts
    65

    VBA Code Option based on data in a cell

    Hello,

    I was wondering if there is a way to write a code stating that if there is data in a certain cell use this code, but if there is not a data in that certain cell use this other code.

    For instance, I have data that should be in 7 column. Sometimes the data being copied is lumped in one column and I would have to use text to column to split it up into the 7 column. Other times the data being copied is copied correctly into the 7 columns.

    So, pretty much if there is data in B1, use the following code:
    Please Login or Register  to view this content.
    If there is no data in cell B1, then use the following code:
    Please Login or Register  to view this content.

    Any help will be appreciated.


    Thank you,
    Miriam
    Last edited by MHamid; 11-26-2013 at 10:28 AM. Reason: Updating post Title

  2. #2
    Registered User
    Join Date
    12-03-2012
    Location
    New Castle, DE
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: VBA Code Question

    Just updated the title ... Does that comply witht the rules?

  3. #3
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: VBA Code Option based on data in a cell

    Hi MHamid,

    That is an easy enough request:

    Please Login or Register  to view this content.
    Jason

  4. #4
    Registered User
    Join Date
    12-03-2012
    Location
    New Castle, DE
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: VBA Code Option based on data in a cell

    Yes!! That worked perfectly.

    Thank you!!

  5. #5
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: VBA Code Option based on data in a cell

    You're welcome. By the way, try to get out of the habit of selecting cells in your code. I know this was a result of recording the macros, but here is an example of what you can change it to. It will be much more efficient:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Two question, numeric code question and subtraction of two columns?
    By mgsweden78 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2008, 02:50 AM
  2. [SOLVED] code question
    By Ana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2006, 05:55 AM
  3. [SOLVED] VBA code question?!
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2006, 12:45 PM
  4. [SOLVED] code question
    By Gary Keramidas in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-19-2005, 01:05 PM

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