LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What have I done wrong with this Macro???


Hi I have written the following Macro to copy specific data int
separate worksheets dependenat on the cell value in columnA.
It works with copying cellValues of '9' into Sheet'9-10' but then i
copies all data with cellValues of '9' or '10' into Sheet'10-11'. I
thisa sheet i only want data with cellValue of '10' to be copied.

Please can you help!!!!!

Sub STEP3()
Dim rng As Range, cell As Range, sel As Range
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "9" Then
If sel Is Nothing Then
Set sel = cell
Else: Set sel = Union(sel, cell)
End If
End If
Next
On Error Resume Next
sel.EntireRow.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("9-10").Select
Range("A3").Select
ActiveSheet.Paste

Sheets("Sheet2").Select
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "10" Then
If sel Is Nothing Then
Set sel = cell
Else: Set sel = Union(sel, cell)
End If
End If
Next
On Error Resume Next
sel.EntireRow.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("10-11").Select
Range("A3").Select
ActiveSheet.Paste
End Su

--
Shandy72
-----------------------------------------------------------------------
Shandy720's Profile: http://www.excelforum.com/member.php...fo&userid=2623
View this thread: http://www.excelforum.com/showthread.php?threadid=39530

 
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
vb macro format is wrong what which is up New Users to Excel 5 February 23rd 10 10:25 PM
What is wrong with this Macro? jeannie v Excel Worksheet Functions 16 February 24th 08 05:05 PM
Calling the wrong macro Philip[_6_] Excel Programming 4 October 25th 04 07:04 PM
Wrong Macro opening oldjay Excel Programming 1 May 6th 04 03:07 PM
What have I got wrong? (Macro),,, ste mac Excel Programming 2 November 7th 03 11:07 AM


All times are GMT +1. The time now is 10:28 AM.

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

About Us

"It's about Microsoft Excel"