G Guest Jun 15, 2007 #1 I have a user selecting a range, how would I put the ending cell in the range in a variable?
G Guest Jun 15, 2007 #3 I guess there's no function for it because End(xldown) only goes to the first blank cell. Thanks for the smart solution
I guess there's no function for it because End(xldown) only goes to the first blank cell. Thanks for the smart solution
B Bernie Deitrick Jun 15, 2007 #4 Note that the code will not work if there are multiple areas selected. In that case: Dim rng As Range Set rng = Selection.Areas(Selection.Areas.Count).Cells(Selection.Areas(Selection.Areas.Count).Cells.Count) HTH, Bernie MS Excel MVP
Note that the code will not work if there are multiple areas selected. In that case: Dim rng As Range Set rng = Selection.Areas(Selection.Areas.Count).Cells(Selection.Areas(Selection.Areas.Count).Cells.Count) HTH, Bernie MS Excel MVP
D Dave Peterson Jun 15, 2007 #5 Check your previous post, too. J@Y said: I have a user selecting a range, how would I put the ending cell in the range in a variable? Click to expand...
Check your previous post, too. J@Y said: I have a user selecting a range, how would I put the ending cell in the range in a variable? Click to expand...
G Guest Jun 15, 2007 #6 Thanks for the note. Bernie Deitrick said: Note that the code will not work if there are multiple areas selected. In that case: Dim rng As Range Set rng = Selection.Areas(Selection.Areas.Count).Cells(Selection.Areas(Selection.Areas.Count).Cells.Count) HTH, Bernie MS Excel MVP Click to expand...
Thanks for the note. Bernie Deitrick said: Note that the code will not work if there are multiple areas selected. In that case: Dim rng As Range Set rng = Selection.Areas(Selection.Areas.Count).Cells(Selection.Areas(Selection.Areas.Count).Cells.Count) HTH, Bernie MS Excel MVP Click to expand...
G Guest Jun 15, 2007 #7 an additional note/added caution is that that method isn't reliable: (to illustrate from the immediate window). Set rng = Selection.Areas(Selection.Areas.Count).Cells(Selection.Areas(Selection.Areas.Count).Cells.Count) ? rng.Address $D$17 ? selection.Address $F$18:$G$21,$C$10:$E$14,$D$16:$D$17 I would have expected G21 to be the result. It depends on how the user selects the range.
an additional note/added caution is that that method isn't reliable: (to illustrate from the immediate window). Set rng = Selection.Areas(Selection.Areas.Count).Cells(Selection.Areas(Selection.Areas.Count).Cells.Count) ? rng.Address $D$17 ? selection.Address $F$18:$G$21,$C$10:$E$14,$D$16:$D$17 I would have expected G21 to be the result. It depends on how the user selects the range.