Locate Change VBA (Intersection)

pantakos

Board Regular
Joined
Oct 10, 2012
Messages
158
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I have the following code that locates and copy cell value (if the cell is >0) from a sheet (AUDIO) to another sheet (PROFORMA DRYHIRE). What I want to do is,if a cell that is already copied to Proforma has beed changed (value), if the new value can be copied to proforma sheet (entire row or the cell value) by overwritten the previous one.
Can I use the Intersection to do that or there is another way?

I have tried various examples with Intersection but no luck :(

PRICE LIST 2021 FINAL.xlsm
BCDEFGHIJK
1
2audio equipment - 1
3
4
5
6
7
8
9
10TOTAL0,00
11
12R1 SPEAKERS QTYPRICE PER DAYPCSAMPLIFIERSQTYPRICE PER DAYPCS
13CLAIR BROS C1216€110,000L-ACOUSTICS LA 4870€30,000
14CLAIR BROS C8 16€50,000L-ACOUSTICS LA 2417€20,000
15CLAIR BROS CS1184€50,000L-ACOUSTICS LA 177€15,000
16L-ACOUSTICS V-DOSC40€80,000L-ACOUSTICS LA 153€20,000
17L-ACOUSTICS dV-DOSC114€30,000L-ACOUSTICS LA 12X32€100,000
18L-ACOUSTICS KUDO6€60,000L-ACOUSTICS LA 4X8€60,000
19L-ACOUSTICS SYVASET L-R€310,000LAB GRUPPEN PLM 12K4410€100,000
20L-ACOUSTICS ARCS WIDE16€40,000LAB GRUPPEN FP 1000010€25,000
21L-ACOUSTICS X1524€45,000LAB GRUPPEN FP C68:46€20,000
22L-ACOUSTICS X1224€35,000POWERSOFT K316€25,000
23L-ACOUSTICS X816€30,000POWERSOFR M50Q16€20,000
24L-ACOUSTICS FM11518€25,000YPSILON M100034€10,000
25L-ACOUSTICS XT-1158€25,000YPSILON M200092€15,000
26L-ACOUSTICS XT-128€20,000YPSILON S100018€15,000
27L-ACOUSTICS MTD 108A12€20,0000
28L-ACOUSTICS KS 2824€80,0000
29L-ACOUSTICS dV-SUB16€25,0000
30L-ACOUSTICS SB1816€35,0000
31EAW SB 100050€25,000PROCESSORSQTYPRICE PER DAYPCS
32NEXO PS1547€20,000DRIVERACK CLAIR -WLS-SMAART-LM441€100,000
33NEXO PS 1012€20,000XTA DP 4486€50,000
34ELECTROVOICE ELX112p18€20,000XTA DP 22616€25,000
35SLS LS 880072€20,000XTA DP 2248€20,000
360LLC 115FM14€5,000
370KLARK TEKNIK DN 80002€25,000
380NEXO TD PS 1531€5,000
390NEXO TD PS 105€5,000
4000
410
420
4300
44TOTAL€0,00TOTAL€0,00
AUDIO
Cell Formulas
RangeFormula
J10J10=SUM(E44,J44,E85,J85,E132,J132,E192,J198)
K32:K43,F43,F13:F40,K13:K30K13=I13*J13
E44,J44E44=SUM(F13:F43)


The sheet (AUDIO) is bigger , just post it for example

PROFORMA-DRYHIRE example

PRICE LIST 2021 FINAL.xlsm
ABCD
1
2ΥΠΕΥΘΥΝΟΣ
3 ΠΡΟΣΦΟΡΑ / PRO-FORMA ΠΕΛΑΤΗΣ
4NO: ΥΠΟΨΙΝ
5ΔΙΕΥΘΥΝΣΗ
6ΠΟΛΗ
7ΑΦΜ
8ΔOY
9ΤΗΛ
10email
11ΠΑΡΑΓΩΓΗ
12ΠΕΡΙΟΔΟΣ
13
14ΤΥΠΟΣ - ΠΕΡΙΓΡΑΦΗΤΕΜΑΧΙΑΤΙΜΗ ΜΟΝΑΔΟΣΣΥΝΟΛΟ
150,00 €
160,00 €
170,00 €
180,00 €
190,00 €
200,00 €
210,00 €
220,00 €
230,00 €
240,00 €
250,00 €
260,00 €
270,00 €
280,00 €
290,00 €
300,00 €
310,00 €
PROFORMA DRYHIRE
Cell Formulas
RangeFormula
D15:D31D15=B15*C15


VBA Code:
Sub BuildInvoiceAudio()

    Dim ws
    Dim i As Long
    Dim cell As Range
    Dim Descript As String
    Dim PPD As Double
    Dim PCS As Long
    Dim nr As Long
    Dim r1 As Range, r2 As Range, r3 As Range, r4 As Range, r5 As Range, r6 As Range, r7 As Range, r8 As Range, r9 As Range, r10 As Range, r11 As Range, r12 As Range, r13 As Range, r14 As Range, myMultiAreaRange As Range
    
    Application.ScreenUpdating = False
   
'   ' Set array of worksheet names to copy from
    ws = Array("AUDIO")
   
    
'   Loop through all shees inthe array
    For i = LBound(ws) To UBound(ws)
        Set r1 = Sheets(ws(i)).Range("E13:E43")
        Set r2 = Sheets(ws(i)).Range("J13:J30")
        Set r3 = Sheets(ws(i)).Range("J32:J43")
        Set r4 = Sheets(ws(i)).Range("E57:E84")
        Set r5 = Sheets(ws(i)).Range("J57:J84")
        Set r6 = Sheets(ws(i)).Range("E100:E131")
        Set r7 = Sheets(ws(i)).Range("J100:J107")
        Set r8 = Sheets(ws(i)).Range("J109:J118")
        Set r9 = Sheets(ws(i)).Range("J120:J131")
        Set r10 = Sheets(ws(i)).Range("E146:E176")
        Set r11 = Sheets(ws(i)).Range("E178:E191")
        Set r12 = Sheets(ws(i)).Range("J146:J176")
        Set r13 = Sheets(ws(i)).Range("J178:J184")
        Set r14 = Sheets(ws(i)).Range("J186:J197")
                        
        Set myMultiAreaRange = Union(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14)
        
'       Iterate through column D on each sheet looking for pieces
        For Each cell In myMultiAreaRange
        
'           See if anything entered in pieces
            If cell > 0 Then
                Descript = cell.Offset(0, -3)  'get description from column B
                PPD = cell.Offset(0, -1) 'get price p/d from column D
                PCS = cell  'get pieces from column E
'               Find next available row in column A on Invoice sheet
                nr = Sheets("PROFORMA DRYHIRE").Cells(Rows.Count, "A").End(xlUp).Row + 1
                If nr < 15 Then nr = 15
'               Populate values on Invoice sheet
                Sheets("PROFORMA DRYHIRE").Cells(nr, "A") = Descript
                Sheets("PROFORMA DRYHIRE").Cells(nr, "B") = PCS
                Sheets("PROFORMA DRYHIRE").Cells(nr, "C") = PPD
            End If
        Next cell
    Next i
   
    Application.ScreenUpdating = False

End Sub

Thank you in advance!
 
After this line:
nr = 14

Add this line:
Sheets("PROFORMA DRYHIRE").Range("A15:C70").ClearContents
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

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