My code does not work. Please take a look.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Please make this code work :)
When i try run this code in single sheet it works without those highlighted in BOLD.

I'm trying to run from one sheet to another...

:)

Code:
Sub try1()
    x = 1
    y = 14
    c = 2
    For chk = x To y
    [B]Sheets("DATAsample").Select[/B]
       If Cells(chk, c).Value = "x" Then
           Cells(chk, c).Offset(0, -1).Resize(, 2).Copy
            [B]Sheets("Sheet1").[/B]Range("D1").Select
            Do Until ActiveCell.Value = ""
            ActiveCell.Offset(1, 0).Select
            Loop
            ActiveSheet.Paste
            
            
    Else
    'nothing
    End If
    Next chk
    Application.CutCopyMode = False
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try

Code:
Sub try1()
Const x As Integer = 1
Const y As Integer = 14
Const c As Integer = 2
Dim chk As Integer
For chk = x To y
    With Sheets("DATAsample")
       If .Cells(chk, c).Value = "x" Then
           .Cells(chk, c).Offset(, -1).Resize(, 2).Copy Destination:=Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Offset(1)
        End If
    End With
Next chk
Application.CutCopyMode = False
End Sub
 
Upvote 0
Great VoG!
Have a great day ahead!;)

Perfect and thanks for sharing new Ideas...at least that as new to me...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top