+ Reply to Thread
Results 1 to 2 of 2

Please help me to adapt this code.

  1. #1
    Rob Hargreaves
    Guest

    Please help me to adapt this code.

    My aim is to have a form and on that page be able to
    click a button, have the form enter the data on the
    datasheet. If one text box is empty it will not write a
    blank over an existing value.

    I have been using the code below and it only allows me to
    write over the existing cells value.

    Set Rng = shData.Range("I" & Application.Match(CLng
    (sh.Range("D6")), shData.Range("B:B"), 0))
    Rng.Value = sh.Range("D8").Text

    I have tried to adapt it and I get an error.

    If sh.Range("D8") Is Null Then
    End
    Else
    Set Rng = shData.Range("E" & Application.Match(CLng
    (sh.Range("D6")), shData.Range("B:B"), 0))
    Rng.Value = sh.Range("D8").Text
    End If

    What do I need to add?
    Also where do I start a message box sayaing

    "Cell "A1" already has a value of 3.22, would you like to
    replace with 2.66?. Click Yes to Replace, No to skip.

  2. #2
    ben
    Guest

    RE: Please help me to adapt this code.

    why not use
    if sh.range("D8").value = "" then
    instead of
    sh.range("d8") is null then
    where exactly do you hit the error?

    "Rob Hargreaves" wrote:

    > My aim is to have a form and on that page be able to
    > click a button, have the form enter the data on the
    > datasheet. If one text box is empty it will not write a
    > blank over an existing value.
    >
    > I have been using the code below and it only allows me to
    > write over the existing cells value.
    >
    > Set Rng = shData.Range("I" & Application.Match(CLng
    > (sh.Range("D6")), shData.Range("B:B"), 0))
    > Rng.Value = sh.Range("D8").Text
    >
    > I have tried to adapt it and I get an error.
    >
    > If sh.Range("D8") Is Null Then
    > End
    > Else
    > Set Rng = shData.Range("E" & Application.Match(CLng
    > (sh.Range("D6")), shData.Range("B:B"), 0))
    > Rng.Value = sh.Range("D8").Text
    > End If
    >
    > What do I need to add?
    > Also where do I start a message box sayaing
    >
    > "Cell "A1" already has a value of 3.22, would you like to
    > replace with 2.66?. Click Yes to Replace, No to skip.
    >


+ 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