+ Reply to Thread
Results 1 to 8 of 8

Posting code with IF

  1. #1
    Robert
    Guest

    Posting code with IF

    The following code is only part of larger posting process. I require
    assistance for this posting to be done only if DG77 is NOT i.e. there must
    be value, zero is not a value. Additional info, the formula in DG77 is
    =IF($DF$8=1,$DF$3,) DF3 has a positive number all the time.

    Set CopyRng = _
    Sheets("Sheet2").Range("DG77", "DH77")
    Set DestRng = _
    Sheets("Sheet1").Cells(65536, "F").End(xlUp).Offset(1, 0)
    i = 0
    For Each cell In CopyRng
    DestRng.Offset(0, i).Value = cell
    i = i + 2
    Next

    Similar postings (without conditions) take place before and after
    the process above.

    Thank you.

    --
    Robert

  2. #2
    Rowan
    Guest

    Re: Posting code with IF

    what about:

    If Sheets("Sheet2").Range("DF8").Value = 1 Then
    Set CopyRng = _
    Sheets("Sheet2").Range("DG77", "DH77")
    Set DestRng = _
    Sheets("Sheet1").Cells(65536, "F").End(xlUp).Offset(1, 0)
    i = 0
    For Each cell In CopyRng
    DestRng.Offset(0, i).Value = cell
    i = i + 2
    Next
    End If

    Hope this helps
    Rowan

    Robert wrote:
    > The following code is only part of larger posting process. I require
    > assistance for this posting to be done only if DG77 is NOT “” i.e. there must
    > be value, zero is not a value. Additional info, the formula in DG77 is
    > =IF($DF$8=1,$DF$3,””) DF3 has a positive number all the time.
    >
    > Set CopyRng = _
    > Sheets("Sheet2").Range("DG77", "DH77")
    > Set DestRng = _
    > Sheets("Sheet1").Cells(65536, "F").End(xlUp).Offset(1, 0)
    > i = 0
    > For Each cell In CopyRng
    > DestRng.Offset(0, i).Value = cell
    > i = i + 2
    > Next
    >
    > Similar postings (without conditions) take place before and after
    > the process above.
    >
    > Thank you.
    >


  3. #3
    Gary Keramidas
    Guest

    Re: Posting code with IF

    will this work for you?

    If Range("DG77") = "" Or Range("dg77") = 0 Then
    ' do nothing
    Else
    'do something your code here
    End If


    --


    Gary


    "Robert" <[email protected]> wrote in message
    news:[email protected]...
    > The following code is only part of larger posting process. I require
    > assistance for this posting to be done only if DG77 is NOT "" i.e. there
    > must
    > be value, zero is not a value. Additional info, the formula in DG77 is
    > =IF($DF$8=1,$DF$3,"") DF3 has a positive number all the time.
    >
    > Set CopyRng = _
    > Sheets("Sheet2").Range("DG77", "DH77")
    > Set DestRng = _
    > Sheets("Sheet1").Cells(65536, "F").End(xlUp).Offset(1, 0)
    > i = 0
    > For Each cell In CopyRng
    > DestRng.Offset(0, i).Value = cell
    > i = i + 2
    > Next
    >
    > Similar postings (without conditions) take place before and after
    > the process above.
    >
    > Thank you.
    >
    > --
    > Robert




  4. #4
    Robert
    Guest

    RE: Posting code with IF

    Thank you Rowan.
    --
    Robert




  5. #5
    Rowan
    Guest

    Re: Posting code with IF

    You're welcome!

    Robert wrote:
    > Thank you Rowan.


  6. #6
    Robert
    Guest

    Re: Posting code with IF

    Thank you Gary, I tried yours after Rowans.
    Special thanks to Rowan and Gary for being so fast.
    --
    Robert




  7. #7
    Gary Keramidas
    Guest

    Re: Posting code with IF

    you're welcome, as long as it worked<g>
    hopefully it worked out ok.

    --


    Gary


    "Robert" <[email protected]> wrote in message
    news:[email protected]...
    > Thank you Gary, I tried yours after Rowans.
    > Special thanks to Rowan and Gary for being so fast.
    > --
    > Robert
    >
    >
    >




  8. #8
    Robert
    Guest

    Re: Posting code with IF

    Gary, of course it works, Rowans as well. I do not know any VBA and had to
    shift the "End If" by trial and error.
    --
    Robert




+ 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