Worksheet_Change Event for 2D pasted array

St Jimmy

New Member
Joined
Oct 29, 2015
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to run a QC process when new data is pasted into a specific portion of a workbook.
I have done this in the past with a 1D array by using the Target(i).Row to iterate through rows. But this will only work for 1D arrays:

VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer

On Error GoTo err
Application.EnableEvents = False

For i = 1 To Rows.Count

    If Target(i).Row < 106 And Target(i).Row > 4 Then
        'Iteration QC goes here...

When I try the above snippet for a 2D paste it just iterates through the first column of all the rows ignoring the other columns.

In past projects I built QC subroutines that pull the whole sheet into an array and QCs the array.
But that's a lot of work and I feel like I can use a property of the Target object to accomplish this without reinventing the wheel.

Does anyone have a link to an example of iterating through each cell of a pasted 2D array using the Worksheet_Change event?
Or am I doomed to an array subroutine?

Thank you!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Does anyone have a link to an example of iterating through each cell
Check this:

 
Upvote 0
Solution
Thank you Dante, I totally forgot about the not intersect strategy!
That should do it! Thanks for saving me some time :)
 
Upvote 0

Forum statistics

Threads
1,225,481
Messages
6,185,249
Members
453,283
Latest member
Shortm88

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