Results 1 to 3 of 3

Code to edit existing data instead of just adding when search

Threaded View

  1. #1
    Registered User
    Join Date
    01-13-2018
    Location
    Manila, Philippines
    MS-Off Ver
    2010
    Posts
    17

    Code to edit existing data instead of just adding when search

    Hi,

    Can someone help me with some codes? I have the code below that searches my raw data and places it on another sheet on specific cells, What I need now is if I edit information and I run this code, it would just edit the information on the raw data and not add it as an additional data.

    Sub LookUp()
    'declare the variable
    Dim Dt As Range, Nn As Range, Rm As Range
    Dim c As Range, orange As Range
    Dim lastrow As Long
    'set object variables
    Set Nn = ActiveCell
    Set Dt = Cells(12, Nn.Column)
    Set Rm = Cells(Nn.Row, 3)
    'set the variable range to loop through
    lastrow = Sheet14.Range("D" & Rows.Count).End(xlUp).Row
    Set orange = Sheet14.Range("D9:D" & lastrow)
    'error handler
    On Error GoTo errHandler:
    'establish data is there and loop
    If Not Range("E13:BH48") Is Nothing Then
    For Each c In orange 'add dynamic range
    '1. has a value 2.Verify Room 3.Look in date range 4. Check the name [optional]
    If c.Value <> 0 And c.Offset(0, -1) = Rm.Value And c.Value <= Dt.Value And c.Offset(0, 2).Value >= Dt.Value Then 'And c.Offset(0, 8).Value = Nn
    'add the values selectively to the top of the calendar
    With Sheet12
    .Range("H3").Value = c.Cells(1, -1).Value
    .Range("V3").Value = c.Cells(1, 0).Value
    .Range("V4").Value = c.Cells(1, 1).Value
    .Range("V5").Value = c.Cells(1, 2).Value
    .Range("V7").Value = c.Cells(1, 4).Value
    .Range("AE3").Value = c.Cells(1, 5).Value
    .Range("AE4").Value = c.Cells(1, 6).Value
    .Range("AE5").Value = c.Cells(1, 7).Value
    .Range("AE6").Value = c.Cells(1, 8).Value
    .Range("AE7").Value = c.Cells(1, 9).Value
    End With
    End If
    Next c
    End If
    'error block
    On Error GoTo 0
    Exit Sub
    errHandler::
    MsgBox "An Error has Occurred " & vbCrLf & "The error number is: " _
    & Err.Number & vbCrLf & Err.Description & vbCrLf & _
    "Please notify the administrator"
    End Sub
    Last edited by cloud.arreglado; 01-14-2018 at 05:27 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Edit Existing VBA Code To Send Out Email Confirming Receipt To Suppliers
    By hoofbeat in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2016, 09:52 PM
  2. [SOLVED] adding a value to existing code
    By bnwash in forum Excel General
    Replies: 16
    Last Post: 06-05-2015, 07:40 PM
  3. Adding to some existing VBA code
    By richard11153 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 03-10-2014, 08:31 PM
  4. [SOLVED] Adding a searchbox and exporting data from a row to a new template (have existing code)
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-09-2013, 06:45 AM
  5. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  6. VBA Code to Search/Edit Data Populated by Userform
    By pjohnson9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2011, 04:25 PM
  7. Help adding to existing code
    By Jrykiss in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-02-2010, 06:11 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