Copy/Paste Range Based on Cell Info

handlit33

Board Regular
Joined
Jul 30, 2003
Messages
81
I need to run a macro that looks at a cell to figure out how many rows down to copy. In other words, if the cell (a1) has "19" in it, then the selection b1:c<b>19</b> would be selected. I have the rest of the code figured out, thanks for your time!
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,092
Select is seldom needed. Here it is with a bit more.
Code:
Sub t()
  Dim r As Range
  If Range("A1").Value <> "" Then
    Set r = Range("B1:C" & Range("A1").Value)
    r.Select
  End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,099,113
Messages
5,466,755
Members
406,497
Latest member
Bryanlim

This Week's Hot Topics

Top