Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Trying to paste into a worksheet

Dear All,

I am using the below to search, copy + paste data into a
worksheet. The code finds the results OK, but isn't
pasting anything, and just jumping straight into the
MsgBox. Any ideas what I've done wrong anyone??

Yours ever so hopefully ;-)

Andy W

------------

Sub BBBBB()
Dim rng As Range
Dim bCopy As Boolean
Sheets("Raw Data").Activate
If ActiveSheet.AutoFilterMode Then _
ActiveSheet.AutoFilterMode = False
With Range("A1")
.AutoFilter Field:=2, Criteria1:="=*Z*"
End With

With ActiveSheet.AutoFilter.Range
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1)
bCopy = False
If .SpecialCells(xlVisible).Columns(1) _
.Rows.Count 1 Then _
bCopy = True
End With
If bCopy Then
rng.Copy Destination:=Sheets("CustbyRDC").Range("A7")
Else
MsgBox "No rows to copy"
End If
ActiveSheet.AutoFilterMode = False
End Sub
..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trying to paste into a worksheet

there shouldn't be a .rows.count. It should just be a .count. My mistake.
Try this one: (worked for me).

Sub BBBBB()
Dim rng As Range
Dim bCopy As Boolean
Sheets("Raw Data").Activate
If ActiveSheet.AutoFilterMode Then _
ActiveSheet.AutoFilterMode = False
With Range("A1")
.AutoFilter Field:=2, Criteria1:="=*Z*"
End With

With ActiveSheet.AutoFilter.Range
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1)
bCopy = False
If .Columns(1).SpecialCells(xlVisible) _
.Count 1 Then _
bCopy = True
End With
If bCopy Then
rng.Copy Destination:=Sheets("CustbyRDC").Range("A7")
Else
MsgBox "No rows to copy"
End If
ActiveSheet.AutoFilterMode = False
End Sub

--
Regards,
Tom Ogilvy

"Andy W" wrote in message
...
Dear All,

I am using the below to search, copy + paste data into a
worksheet. The code finds the results OK, but isn't
pasting anything, and just jumping straight into the
MsgBox. Any ideas what I've done wrong anyone??

Yours ever so hopefully ;-)

Andy W

------------

Sub BBBBB()
Dim rng As Range
Dim bCopy As Boolean
Sheets("Raw Data").Activate
If ActiveSheet.AutoFilterMode Then _
ActiveSheet.AutoFilterMode = False
With Range("A1")
.AutoFilter Field:=2, Criteria1:="=*Z*"
End With

With ActiveSheet.AutoFilter.Range
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1)
bCopy = False
If .SpecialCells(xlVisible).Columns(1) _
.Rows.Count 1 Then _
bCopy = True
End With
If bCopy Then
rng.Copy Destination:=Sheets("CustbyRDC").Range("A7")
Else
MsgBox "No rows to copy"
End If
ActiveSheet.AutoFilterMode = False
End Sub
.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy & paste worksheet with print settings into new worksheet Larry Ohio Excel Discussion (Misc queries) 1 December 23rd 09 05:17 PM
Cut and Paste from one worksheet to another? Labrador_Pride Excel Discussion (Misc queries) 1 June 12th 09 09:30 PM
Need to cut and paste worksheet R New Users to Excel 1 February 13th 06 08:37 PM
excel 97: copy and paste values from one worksheet to another worksheet JMCN Excel Programming 2 September 23rd 03 01:32 PM
excel 97: copy and paste values from one worksheet to another worksheet Kathy[_5_] Excel Programming 0 September 21st 03 03:03 PM


All times are GMT +1. The time now is 12:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"