Code for activating shift key

G

Guest

I need help with finding code that will virtually hold down the shift key. I
code that will select one cell and then i have it finding a second cell but I
it to "hold the shift key" inbetween so it copies all of the cels inbetween.
See below for the code i have so far. thank you!

Private Sub CommandButton1_Click()
Dim rng As Range
Dim cell As Range

Set rng = Range("B1:B1000")

startrow = Columns(2).Find("example 1").Select
ActiveCell.Copy

****Hold shift key****

startrow = Columns(2).Find("example 2").Select
ActiveCell.Copy

***End holding shift key****


End Sub
 
J

JE McGimpsey

How about:

Private Sub CommandButton1_Click()
Dim r1 As Range
Dim r2 As Range

With Range("B:B")
Set r1 = .Find("example 1")
If Not r1 Is Nothing Then
Set r2 = .Find("example 2")
If Not r2 Is Nothing Then
Range(r1, r2).Copy _
Destination:=Sheets("Sheet2").Range("A1")
End If
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top