VBA - change "target" to certain cell

oggy3000

Board Regular
Joined
Jul 13, 2011
Messages
51
Hey guys,
I am currently trying to expand some formula with VBA but dont really have deep knowledge about it.
I found the following code and if used as intended (Double click on a cell), it works fine.

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   Cancel = True   'Eliminate Edit status due to doubleclick
    [I][COLOR=#339966]target[/COLOR][/I].Offset(1).EntireRow.Resize([B]3[/B]).Insert
    [I][COLOR=#339966]target[/COLOR][/I].EntireRow.Copy [I][COLOR=#339966]target[/COLOR][/I].EntireRow.Offset(1).Resize([B]3[/B]).EntireRow
    on error resume next
    [I][COLOR=#339966]target[/COLOR][/I].Offset(1).EntireRow.Resize([B]3[/B]).SpecialCells(xlConstants).ClearContents
    on error goto 0
End Sub

However, when I try to change it to my needs, I always get error messages.
Here is what I want to to do:
Klick on a button and then expand formulas in a sheet ("INVOICE") for the number of rows in Sheet "Bondout List".

So i tried to do the following:
Count the number of rows for column "E" on Sheet "Bondout List" by this:

Code:
Dim varlastRow As Long
varlastRow = Worksheets("Bondout List").Cells(65536, 5).End(xlUp).Row - 9
and use this value instead of the "3".

After that I tried to change the "Target" stuff because I want Row 9 to be used but I always get "Object required". So I think, its only depending on getting the stuff with the target cleared.

Hope you can help me with a little change of the code.

Cheers
Jan
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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