Macro to select last cell with text when there are formulas in the cells

Silverhorne

New Member
Joined
Feb 21, 2015
Messages
42
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Good Day!
I have been looking for a solution for this but have haven't been able to find the answer anywhere, my last resort is to post here, hopefully someone can help.

I am trying to create a macro that copies certain cells (C2 to C?) to the clipboard, these cells are populated depending on the number of tests completed to the item.
The cells in C2 to C7 are always populated but cell C5 is always blank.
I would like to copy the cells where the formula displays text, the dynamic cells will be C8 to C14.
The macro below finds the last row with formulas .End(xlUp) this is not what I want.

Sub SELECT_FOR_MAPPING()

Lrow = Range("C" & Rows.Count).End(xlUp).Row
Range("C2:C" & Lrow).Copy

End Sub

It important to know that the formulas in cells C9 to C14 have a formula that will leave a space in the cell, so they may appear to have text when it is just a space.
I have created a numbered list in B2 to B14 to use as a reference for a count function but I am not sure how to string the code together as am pretty new to the code part of excel.
Sorry, I can't get Xl2bb to do a mini sheet, only a table...I think it might have to do with the large formulas pulling the data into these cells.
Thanks in advance for any help.

11 128-MS-1-24-4128-MS-1-24-411
2 CCI-ST-8
3 18/Feb/2023
4
5 LH LH C14 C14
6 CR CR PG PG
7 MD 24"/12.7 mm
8PH: test1
9RT: 20230218 RT TLH-01
10RT1: test1
11RT2: test1
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try
VBA Code:
LRow = Evaluate("MAX(IF(C1:C10000<>"""",ROW(C1:C10000),""""))")
 
Upvote 0
That is still copying all cells from C2 to C14.
Here is the macro I tried along with the formula that is in cells C8 to C14.

Sub SELECT_FOR_MAPPING()

lRow = Evaluate("MAX(IF(C1:C10000<>"""",ROW(C1:C10000),""""))")
Range("C2:C" & lRow).Copy

End Sub

=(IF(ISNA(INDEX(Hidden!$G$3:$G$13,MATCH(1,Hidden!$F$3:$F$13,FALSE),1)),"",INDEX(Hidden!$G$3:$G$13,MATCH(1,Hidden!$F$3:$F$13,FALSE),1))&" "&IF(ISNA(INDEX(Hidden!$H$3:$H$13,MATCH(1,Hidden!$F$3:$F$13,FALSE),1)),"",INDEX(Hidden!$H$3:$H$13,MATCH(1,Hidden!$F$3:$F$13,FALSE),1)))

This does an index match, adds a space, and does another index match.

Thank you for your answer.
 
Upvote 0
Could you attach an XL2BB minisheet where formulas and cell coordinates are visible?
 
Upvote 0
I've tried to use the mini sheet option on both of my computers and on different ranges of cells with formulas and it keeps crashing excel.
I looking at the help forum for XL2BB to see if I can make it work....
 
Upvote 0
I tried my best to duplicate what I have in the original sheet, if the solution works on this, it should work on the original sheet.

Select Copy Macro.xlsm
BCDEF
21 128-MS-1-24-41 128-MS-1-24-4
32 CCI-ST-82 CCI-ST-8
43 18/Feb/20233 18/Feb/2023
544
65 LH LH C14 C145 LH LH C14 C14
76 CR CR PG PG 6 CR CR PG PG
87 MD 24"/12.7 mm7 MD 24"/12.7 mm
98PH: test18PH: test1
109RT: 20230218 RT TLH-019RT: 20230218 RT TLH-01
1110RT1: test110RT1: test1
1211RT2: test111RT2: test1
13  12
14  13
Sheet1
Cell Formulas
RangeFormula
C2:C4,C6:C14C2=IF(F2=""," ",F2)
B9:B14B9=IF(C9=" ","",B8+1)
 
Upvote 0
I missed that the formula returns a "Space" :(
Try
VBA Code:
LRow = Evaluate("MAX(IF(len(C1:C10000)>1,ROW(C1:C10000),""""))")
This assumes that a string longer than 1 character is returned by the formula, or one Space; could it work?
 
Upvote 1
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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