Updating a Row Base on a selected Unique Cell Value using VBA

ANTHONY011897

New Member
Joined
May 1, 2023
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. MacOS
Hi, I am new with VBA and I have a workbook that looks like this:

Sheet1 = Database
Sheet2= Search and Update

On Sheet2, I want to put a search and update button where the user can just put the unique ID of the cell from Database.

I haven't use yet any code since I can't find online.
I have attached the sample table of my database, and i want to search and update a data using case id.
 

Attachments

  • Screen Shot 2023-05-01 at 2.04.11 PM.png
    Screen Shot 2023-05-01 at 2.04.11 PM.png
    56.8 KB · Views: 8

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Sheet1 - Database
Book1
ABCDEFGHIJ
1Processed DateCase NumberFromToCCCSPCase SummaryCommentsStatusTime Status Was Change
245239C2310.06440.580.70.4OkPending0.908736376
345088C2320.940.730.70.97Not okCompleted0.764701878
445024C2310.07750.840.30.15Not okCancelled0.621706851
545222C2310.85390.910.50.07OkCancelled0.223434279
645139C2310.20590.540.20.68OkCompleted0.014951483
745096C2320.86410.490.40.39OkCompleted0.699653795
845141C2320.44480.370.30.88OkCompleted0.174962553
944989C2320.63750.850.50.2OkCompleted0.680569642
1045283C2320.21330.750.10.08OkCompleted0.174060058
1145179C2320.02950.030.20.78OkCompleted0.393235256
1245177C89890.65840.880.50.94OkCompleted0.137053226
1345048C2320.71090.3910.32Not okCompleted0.698482822
1445234C2320.79140.0310.61Not okPending0.0364103
1544962C89890.66030.770.30.25Not okPending0.8390586
1644976C2310.23890.240.20.76Not okPending0.479685147
1745083C89890.55320.10.40.29Not okPending0.007211494
1844987C2310.66040.210.90.21Not okPending0.832374965
1944938C2310.44350.740.30.58Not okPending0.252941604
2045151C89890.4380.770.70.57Not okPending0.870089433
Sheet1


Sheet2 = Filter
Book1
ABCDEFGHIJKLM
1Case NumberProcessed DateFromToCCCSPCase SummaryCommentsStatusTime Status Was ChangeCase NumberCase Number
2C8989451770.6584290.8778050.4941940.935922OkCompleted0.137053226C231C8989
3C8989449620.6602620.7704530.3139190.252828Not okPending0.8390586C232
4C8989450830.5532020.102880.4203990.294787Not okPending0.007211494C8989
5C8989451510.4379640.7732480.7376620.567655Not okPending0.870089433
Sheet2


sheet2 - view code - paste the code below
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

  If Not Intersect(Target, Range("L2:L200")) Is Nothing Then 'Case number
    Cancel = True
 
    Application.ScreenUpdating = False
    Dim sh1 As Worksheet
    Set sh1 = Sheets(1) 'Sheet 1 = Database
    Range("m2").Value = Target.Value
    Range("A2:j" & Rows.Count).ClearContents
 

     sh1.Range("A1:j" & sh1.Range("A" & Rows.Count).End(3).Row).AdvancedFilter _
    Action:=xlFilterCopy, CriteriaRange:=Range("m1:m2"), CopyToRange:=Range("A1:J1"), Unique:=False
    'A1:J = sheet 1 range, if adding new column you may change your column range since there's not dynamic yet
    'Range m1:m2 based in sheet2 case number
  Application.ScreenUpdating = True
 
  End If
End Sub

Hi, while waiting for other experts, i will share my thought here for your ref.

this one filter by using double click, you may put the case number in L2 or below and then double click with it. (unfortunately still not yet able for updating value)

Im still waiting for other reference as well since i've been using this, would like to check if got better option :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,361
Messages
6,136,103
Members
449,991
Latest member
IslandofBDA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top