Button to add data from 1st Sheet to 2nd Sheet based on criteria

rizalyaakub

New Member
Joined
Nov 6, 2022
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
I am rather new at VBA. Mostly learning it via youtube video.

I need a little guidance for VBA code that would allow me,

1. When I click the "UPDATE RECEIPT" button, it adds / updates value marked as A (in the RECEIPT sheet) to ROW C in the DATABASE sheet based on corresponding Invoice number marked as B

1.png


2.png


I found a previous posting online and tried using it as based but failed miserably.

VBA Code:
Option Explicit

Dim x As Integer

Sub Button1_Click()

x = 1

'this will find the column that matches the date and stores that as the copy location.
While Sheets("Sheet2").Cells(1, x).Value <> Sheets("Sheet1").Range("L8")
    x = x + 1
Wend


'this portion copies the data to the designated coordinates found by the first portion and delete the information from L8 and L11.
Sheets("Sheet2").Cells(2, x).Value = Sheets("Sheet1").Range("L11").Value
Sheets("Sheet1").Range("L8").Value = ""


End Sub

Really need your help :)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Accidently left my VB code. >

VBA Code:
Sub RecordReceipt()

x = 1

'this will find the column that matches the date and stores that as the copy location.
While Sheets("Sheet10").Cells(1, x).Value <> Sheets("Sheet9").Range("J15")
    x = x + 1
Wend


'this portion copies the data to the designated coordinates found by the first portion and delete the information from L8 and L11.
Sheets("Sheet10").Cells(2, x).Value = Sheets("Sheet9").Range("Receipt!H5").Value
Sheets("Sheet10").Range("").Value = ""


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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