VBA to double-click through a range

jnathan

New Member
Joined
Jul 8, 2013
Messages
48
I am trying to get my code to double-click through a range in column B. The range is determined based on the where there is a blank cell in column A - see code below.

The issue I'm having is that the double-click works for the first cell within the range but it then jumps to the first cell falling outside the range and contiues to double-click through these subsequent blank cells.

Just by way of info, the purpose of doing this is to automate double-clicks through a range so as to activate a Worksheet_Change routine within the spreadsheet

Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)</SPAN></SPAN>
Y = Range("A" & Rows.Count).End(xlUp).Row + 1</SPAN></SPAN>
Z = Range("B" & Rows.Count).End(xlUp).Row</SPAN></SPAN>
Dim i As Integer</SPAN></SPAN>
For i = Y To Z</SPAN></SPAN>
    Cells(i, 2).Select</SPAN></SPAN>
    SendKeys "{F2}", True</SPAN></SPAN>
    SendKeys "{ENTER}", True</SPAN></SPAN>
Next i</SPAN></SPAN>
End Sub</SPAN></SPAN>

Any help would be greatly appreciated :)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
clarify dbl-click. Do mean you dbl-click on a cell and it autofills thru the data?
And what is in the range? dates? numbers?
 
Upvote 0
clarify dbl-click. Do mean you dbl-click on a cell and it autofills thru the data?
And what is in the range? dates? numbers?

I have a Worksheet_Change routine that is activated by a cell in column B being dbl-clicked (it basically conducts a Vlookup but that's beside the point). As there can be quite a number of cells in column B I want to be able to identify the newly populated cells in column B so that, by right-clicking (for example), the entire range is worked through by the macro and each cell within the range is double-clicked so that the Worksheet_Change routine is activated for each cell within the range.

Hope this helps explain things further but let me know if you need more info
 
Upvote 0

Forum statistics

Threads
1,215,457
Messages
6,124,941
Members
449,197
Latest member
k_bs

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