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!
 
Try this

VBA Code:
Sub BuildInvoiceAudio()
  Dim ws As Variant, arr As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range, MultiRange As Range
  Dim Descript As String
   
  Application.ScreenUpdating = False
  '   ' Set array of worksheet names to copy from
  ws = Array("AUDIO")
  arr = Array("E13:E43", "J13:J30", "J32:J43", "E57:E84", "J57:J84", "E100:E131", "J100:J107", _
        "J109:J118", "J120:J131", "E146:E176", "E178:E191", "J146:J176", "J178:J184", "J186:J197")
  '   Loop through all shees inthe array
  For i = LBound(ws) To UBound(ws)
    Set MultiRange = Sheets(ws(i)).Range("A" & Rows.Count).End(3)(2)
    For j = 0 To UBound(arr)
      Set MultiRange = Union(MultiRange, Sheets(ws(i)).Range(arr(j)))
    Next
    For Each cell In MultiRange         'Loop through all cells inthe multirange
      If cell > 0 Then                  'See if anything entered in pieces
        Descript = cell.Offset(0, -3)   'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
            If nr < 15 Then nr = 15
          End If
          '               Populate values on PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub
You are the best !
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
@DanteAmor ok... Its me again. When I run the sub, it displays the message that Rows are Full, even though they are not.

Here is the full code. There are four subs (Audio, Lights, Truss, Distro) so maybe because I have activate all, there is the error.

VBA Code:
Sub Macro1()

    Call BuildInvoiceAudio
    Call BuildInvoiceLIGHTS
    Call BuildInvoiceHTD
    Call BuildInvoiceDCM

End Sub

Sub BuildInvoiceAudio()
  Dim ws As Variant, arr As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range, MultiRange As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  '   ' Set array of worksheet names to copy from
  ws = Array("AUDIO")
  arr = Array("E13:E43", "J13:J30", "J32:J43", "E57:E84", "J57:J84", "E100:E131", "J100:J107", _
        "J109:J118", "J120:J131", "E146:E176", "E178:E191", "J146:J176", "J178:J184", "J186:J197")
  '   Loop through all shees inthe array
  For i = LBound(ws) To UBound(ws)
    Set MultiRange = Sheets(ws(i)).Range("A" & Rows.Count).End(3)(2)
    For j = 0 To UBound(arr)
      Set MultiRange = Union(MultiRange, Sheets(ws(i)).Range(arr(j)))
    Next
    For Each cell In MultiRange         'Loop through all cells inthe multirange
      If cell > 0 Then                  'See if anything entered in pieces
        Descript = cell.Offset(0, -3)   'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
            If nr < 15 Then nr = 15
          End If
          '               Populate values on PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub

Sub BuildInvoiceLIGHTS()
  Dim ws As Variant, arr As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range, MultiRange As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  '   ' Set array of worksheet names to copy from
  ws = Array("LIGHTS")
  arr = Array("E13:E34", "J13:J59", "E36:E59", "E73:E89", "J73:J82", "J84:J91", "E91:E98", "J93:J101", "E100:E109", "J103:J113")
  '   Loop through all shees inthe array
  For i = LBound(ws) To UBound(ws)
    Set MultiRange = Sheets(ws(i)).Range("A" & Rows.Count).End(3)(2)
    For j = 0 To UBound(arr)
      Set MultiRange = Union(MultiRange, Sheets(ws(i)).Range(arr(j)))
    Next
    For Each cell In MultiRange         'Loop through all cells inthe multirange
      If cell > 0 Then                  'See if anything entered in pieces
        Descript = cell.Offset(0, -3)   'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
            If nr < 15 Then nr = 15
          End If
          '               Populate values on PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub

Sub BuildInvoiceHTD()
  Dim ws As Variant, arr As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range, MultiRange As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  '   ' Set array of worksheet names to copy from
  ws = Array("HOISTS - TRUSS - DRAPES")
  arr = Array("E13:E28", "K13:K37", "E30:E40", "E42:E52", "E67:E91", "K67:K85", "E106:E123", "K106:K119", "K121:K129", "E127:E137")
  '   Loop through all shees inthe array
  For i = LBound(ws) To UBound(ws)
    Set MultiRange = Sheets(ws(i)).Range("A" & Rows.Count).End(3)(2)
    For j = 0 To UBound(arr)
      Set MultiRange = Union(MultiRange, Sheets(ws(i)).Range(arr(j)))
    Next
    For Each cell In MultiRange         'Loop through all cells inthe multirange
      If cell > 0 Then                  'See if anything entered in pieces
        Descript = cell.Offset(0, -3)   'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
            If nr < 15 Then nr = 15
          End If
          '               Populate values on PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub

Sub BuildInvoiceDCM()
  Dim ws As Variant, arr As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range, MultiRange As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  '   ' Set array of worksheet names to copy from
  ws = Array("DISTRO - CABLES - MISC")
  arr = Array("E13:E35", "K13:K50", "E37:E50", "E64:E116", "K64:K88", "K92:K108", "K111:K120", "E131:E148", "K131:K148", "K150:K159", _
  "E152:E180", "K163:K188", "K190:K203", "E184:E216", "K207:K238", "K240:K249")
  '   Loop through all shees inthe array
  For i = LBound(ws) To UBound(ws)
    Set MultiRange = Sheets(ws(i)).Range("A" & Rows.Count).End(3)(2)
    For j = 0 To UBound(arr)
      Set MultiRange = Union(MultiRange, Sheets(ws(i)).Range(arr(j)))
    Next
    For Each cell In MultiRange         'Loop through all cells inthe multirange
      If cell > 0 Then                  'See if anything entered in pieces
        Descript = cell.Offset(0, -3)   'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
            If nr < 15 Then nr = 15
          End If
          '               Populate values on PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub
 

Sub ClearContents()
'   Clear All contents from Sheet - Proforma
    Worksheets("PROFORMA DRYHIRE").Range("A15:C70").ClearContents
    MsgBox "Ç öüñìá êáèÜñéóå!"
End Sub

Thank you !!!
 
Upvote 0
Check the data in each sheet, maybe there are hidden rows or hidden values that you are not seeing and it is being passed to the sheet "PROFORMA DRYHIRE"

Also check that in the "PROFORMA DRYHIRE" sheet there is no data after row 70 or any text that you have put after cell A70 or blank spaces after cell A70.
 
Upvote 0
Check the data in each sheet, maybe there are hidden rows or hidden values that you are not seeing and it is being passed to the sheet "PROFORMA DRYHIRE"

Also check that in the "PROFORMA DRYHIRE" sheet there is no data after row 70 or any text that you have put after cell A70 or blank spaces after cell A70.
There are data after row 70, some data and blank spaces etc that are needed to be there. Of cource if there is no other solution I can move them. My though was that if rows A15 to A70 gets full then there will be a message.
 
Upvote 0
Ok, there is an error in the logic of your original macro, I make the correction and I put the macro here.
 
Upvote 0
Try this.
One macro for all your sheets

VBA Code:
Sub BuildInvoiceAll()
  Dim ws As Variant, arr1 As Variant, arr2 As Variant, arr3 As Variant, arr4 As Variant, arry As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range, MultiRange As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  'Set array of worksheet names to copy from
  ws = Array("AUDIO", "LIGHTS", "HOISTS - TRUSS - DRAPES", "DISTRO - CABLES - MISC")
  
  'cells to AUDIO sheet
  arr1 = Array("E13:E43", "J13:J30", "J32:J43", "E57:E84", "J57:J84", "E100:E131", "J100:J107", _
        "J109:J118", "J120:J131", "E146:E176", "E178:E191", "J146:J176", "J178:J184", "J186:J197")
  'cells to LIGHTS sheet
  arr2 = Array("E13:E34", "J13:J59", "E36:E59", "E73:E89", "J73:J82", "J84:J91", "E91:E98", "J93:J101", "E100:E109", "J103:J113")
  'cells to HOISTS sheet
  arr3 = Array("E13:E28", "K13:K37", "E30:E40", "E42:E52", "E67:E91", "K67:K85", "E106:E123", "K106:K119", "K121:K129", "E127:E137")
  'cells to DISTRO sheet
  arr4 = Array("E13:E35", "K13:K50", "E37:E50", "E64:E116", "K64:K88", "K92:K108", "K111:K120", "E131:E148", "K131:K148", "K150:K159", _
         "E152:E180", "K163:K188", "K190:K203", "E184:E216", "K207:K238", "K240:K249")
  
  arry = Array(arr1, arr2, arr3, arr4)
  nr = 14
  'Loop through all shees inthe array
  For i = LBound(ws) To UBound(ws)
    Set MultiRange = Sheets(ws(i)).Range("A" & Rows.Count).End(3)(2)
    For j = 0 To UBound(arry(i))
      Set MultiRange = Union(MultiRange, Sheets(ws(i)).Range(arry(i)(j)))
    Next
    For Each cell In MultiRange         'Loop through all cells inthe multirange
      If cell > 0 Then                  'See if anything entered in pieces
        Descript = cell.Offset(0, -3)   'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = nr + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
          End If
          '               Populate values in PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub
 
Upvote 0
Here another enhancement. Multi range is not necessary.

VBA Code:
Sub BuildInvoiceAll()
  Dim ws As Variant, arr1 As String, arr2 As String, arr3 As String, arr4 As String, arry As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  'Set array of worksheet names to copy from
  ws = Array("AUDIO", "LIGHTS", "HOISTS - TRUSS - DRAPES", "DISTRO - CABLES - MISC")
  
  'cells to AUDIO sheet
  arr1 = "E13:E43, J13:J30, J32:J43, E57:E84, J57:J84, E100:E131, J100:J107," & _
        "J109:J118, J120:J131, E146:E176, E178:E191, J146:J176, J178:J184, J186:J197"
  'cells to LIGHTS sheet
  arr2 = "E13:E34, J13:J59, E36:E59, E73:E89, J73:J82, J84:J91, E91:E98, J93:J101, E100:E109, J103:J113"
  'cells to HOISTS sheet
  arr3 = "E13:E28, K13:K37, E30:E40, E42:E52, E67:E91, K67:K85, E106:E123, K106:K119, K121:K129, E127:E137"
  'cells to DISTRO sheet
  arr4 = "E13:E35, K13:K50, E37:E50, E64:E116, K64:K88, K92:K108, K111:K120, E131:E148, K131:K148, K150:K159," & _
         "E152:E180 , K163:K188 , K190:K203 , E184:E216 , K207:K238 , K240:K249 "
  arry = Array(arr1, arr2, arr3, arr4)
  nr = 14
  
  For i = LBound(ws) To UBound(ws)                  'Loop through all shees inthe array
    For Each cell In Sheets(ws(i)).Range(arry(i))   'Loop through all cells inthe multirange
      If cell > 0 Then                              'See if anything entered in pieces
        Descript = cell.Offset(0, -3)               'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = nr + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
          End If
          '               Populate values in PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub
 
Upvote 0
Solution
Here another enhancement. Multi range is not necessary.

VBA Code:
Sub BuildInvoiceAll()
  Dim ws As Variant, arr1 As String, arr2 As String, arr3 As String, arr4 As String, arry As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range
  Dim Descript As String
   
  Application.ScreenUpdating = False
  'Set array of worksheet names to copy from
  ws = Array("AUDIO", "LIGHTS", "HOISTS - TRUSS - DRAPES", "DISTRO - CABLES - MISC")
 
  'cells to AUDIO sheet
  arr1 = "E13:E43, J13:J30, J32:J43, E57:E84, J57:J84, E100:E131, J100:J107," & _
        "J109:J118, J120:J131, E146:E176, E178:E191, J146:J176, J178:J184, J186:J197"
  'cells to LIGHTS sheet
  arr2 = "E13:E34, J13:J59, E36:E59, E73:E89, J73:J82, J84:J91, E91:E98, J93:J101, E100:E109, J103:J113"
  'cells to HOISTS sheet
  arr3 = "E13:E28, K13:K37, E30:E40, E42:E52, E67:E91, K67:K85, E106:E123, K106:K119, K121:K129, E127:E137"
  'cells to DISTRO sheet
  arr4 = "E13:E35, K13:K50, E37:E50, E64:E116, K64:K88, K92:K108, K111:K120, E131:E148, K131:K148, K150:K159," & _
         "E152:E180 , K163:K188 , K190:K203 , E184:E216 , K207:K238 , K240:K249 "
  arry = Array(arr1, arr2, arr3, arr4)
  nr = 14
 
  For i = LBound(ws) To UBound(ws)                  'Loop through all shees inthe array
    For Each cell In Sheets(ws(i)).Range(arry(i))   'Loop through all cells inthe multirange
      If cell > 0 Then                              'See if anything entered in pieces
        Descript = cell.Offset(0, -3)               'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = nr + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
          End If
          '               Populate values in PROFORMA sheet
          .Cells(nr, "A") = Descript
          .Cells(nr, "B") = cell                  'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)    'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub
Everything is ok! Thank you so much !
 
Upvote 0
Again with pleasure. Thanks for the feedback
@DanteAmor something last ... is it possible if I erase a value in source cells (audio, lights etc) when I run the macro to check if there is a change to delete it from target (proforma) ? Just the one that gone from a value (lets say 5) to nothing , not 0 , delete the value from target sheet (proforma)

Is it?

Thank you !!!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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