We help IT Professionals succeed at work.
Get Started

Loop..........Copy Range and offset

NYQuicksale asked
Last Modified: 2012-05-11
i've a code that copy data from one sheet and paste it into another,but when  attached with the loop, the copyprices code don't work,just loop runs and ends without copying,just the range is offset


Dim ws1 As Worksheet
Dim ws2 As Worksheet

Set ws1 = Sheets("PRICES")
Set ws2 = Sheets("SHEET1")

ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues

End Sub

Open in new window

my loop code is

Sub loopA()
Dim cel As Range
For Each cel In Range("A1:A" & Range("A1").End(xlDown).Row)
[h1] = cel.Value
Next cel
End Sub

Open in new window

i've associated cell H1 with worksheet change in prices sheet and the code is
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim sts As String

sts = Range("$H$1").Value

If Target.Address = "$H$1" Then


End If

End Sub

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE