+ Reply to Thread
Results 1 to 9 of 9

VBA If Statement

  1. #1
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    VBA If Statement

    I am trying to get the following IF Statement to work in VBA. I want it to paste a value in the D cells if the D cell is empty and the C cells are not empty. Thanks in advance for the help.

    If Range("C:C") Is Not Null And Range("D:D") Is Null Then Range("D:D") = Range("A2").Value

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA If Statement

    How about:

    Please Login or Register  to view this content.
    Gary's Student

  3. #3
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    Re: VBA If Statement

    this did not fill the cells with A2. I used the code above. Any thoughts?

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA If Statement

    Here is my test of the macro
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    Re: VBA If Statement

    i am trying to get it to only paste in d6 since there is a value in c6. currently, it is filling in the entire D column. Also, if there is a value in both c and D i want it to skip that value and move to the next. Thanks

  6. #6
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA If Statement

    Then how about:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    Re: VBA If Statement

    I was getting an Error 424:Object Required and it was highlighting "For Each dd In D"

  8. #8
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA If Statement

    I will check.

  9. #9
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    Re: VBA If Statement

    It worked with the following:. What I am trying to do on another sheet is to say is D:D contains a date with format mm/dd/yyyy, then format the respective cell in C:C with a date format also.

    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)

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