calling a macro and placing data

B-Man

Board Regular
Joined
Dec 29, 2012
Messages
185
Office Version
  1. 2019
Platform
  1. Windows
Hi, i have a sheet where i have set the filter so i can filter out items

i have found a macro to select the first cell in column A
Code:
ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select

and a macro to select the last cell in column A
Code:
Range("A" & Rows.Count).End(xlUp).Select

they might not be great but they seem to work fine

what im after is to somehow run the macro every time i change a filter option and get the value of last cell in column A - (take) the value of the first cell in column A and place that answer into E5
 
cant seem to edit that post for some reason

i have my formula worked out now but just need to work out how to make it automatically run when i change the filters

Code:
Sub BillsFirstLast()
ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 1).Select
Selection.Copy

Range("R2").Select

Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False


Range("A" & Rows.Count).End(xlUp).Select
Selection.Copy

Range("R3").Select

Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False

End Sub
 
Upvote 0
i cant edit... yet it says you may edit your posts in the posting permissions..?

im still having trouble calling the macro
i think its because im trying to call it from a cell that is a formula?

what i want to do is run the macro when a filter changes but i cant find anything about that

then i decided to run the macro based on a cell change but i cant get that working..
the cell has a formula so i think thats where the problem is but i can get it working

id like to run the macro every time the cell D3 changes but cant get anything working?

im doing it in the correct area (sheet code)

the formula in D3 is
Code:
=SUBTOTAL(9,D4:D509)
 
Last edited:
Upvote 0

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