troubleshooting Question

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

Avatar of NYQuicksale
NYQuicksaleFlag for United States of America asked on
VB ScriptMicrosoft Excel
4 Comments1 Solution410 ViewsLast Modified:
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

Sub COPYPRICES()

Dim ws1 As Worksheet
Dim ws2 As Worksheet

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

ws1.Range("T1:AT225").Copy
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

Call COPYPRICES

End If

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
StephenJR

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 4 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 4 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004