Cell reference to output cell macro

petegrant89

New Member
Joined
Jun 28, 2011
Messages
21
I have data in Columns A-BI in groups of rows ranging in number (each group will have a different amount of rows every time the report is run). The groups of data are separated by a row of blank cells. I have been trying to design a macro where I can place my cursor underneath the group of data in column BI, and when I run the macro a designated output cell is populated with the cell reference (coordinates) of the top non-blank cell in column BI before the blank row.

Note: the problem I have been having is that I need this macro to function with all groups of data going down the page, which vary in terms of how many rows they consist of. I need this macro to populate the output cell with the cell reference of the top non-blank cell before the blank row in the group of data that my ActiveCell is currently under, so I can run the same macro for each group of data on the page.

Any suggestions?
 
This compiles OK:

Code:
.FormulaR1C1 = "=IF(R[-1]C[1]"">""0,COUNTIF(R" & x & "C[-2]:R[1]C[-2],""<=""&R[-2]C[1]),IF(R[-1]C[1]""=""0,COUNTIF(R" & x & "C[-2]:R[1]C[-2],""<=""&R[-2]C[1])+1))"

I had to add some more double quotes.
 
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).
When I run that one it returned a Run-time error 1004: Application-defined or object-defined error. I looked it up and it involves "LegendEntries" - I do not quite understand what that error entails.
 
Upvote 0
Try:

.FormulaR1C1 = "=IF(R[-1]C[1]>0,COUNTIF(R" & x & "C[-2]:R[1]C[-2],""<=""&R[-2]C[1]),IF(R[-1]C[1],""=0"",COUNTIF(R" & x & "C[-2]:R[1]C[-2],""<=""&R[-2]C[1])+1))"
 
Upvote 0
Yes... perfect. Thank you again for all your help - you've saved me hours of monotony per week. Additionally, do you have any suggestions for books for me to pick up to learn VBA better for excel? I've been learning a lot by just playing with code and changing it to fit my needs but as you can see my coding is sloppy and verbose; I'd like to learn to write more efficient codes.
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,967
Members
449,276
Latest member
surendra75

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