Excel Macro deleting unwanted info
Closed
jer
-
Aug 31, 2010 at 10:38 AM
RayH Posts 122 Registration date Tuesday August 31, 2010 Status Contributor Last seen June 20, 2016 - Sep 2, 2010 at 07:01 PM
RayH Posts 122 Registration date Tuesday August 31, 2010 Status Contributor Last seen June 20, 2016 - Sep 2, 2010 at 07:01 PM
Related:
- Excel Macro deleting unwanted info
- Spell number in excel without macro - Guide
- Excel marksheet - Guide
- Excel free download - Download - Spreadsheets
- Macros in excel download - Download - Spreadsheets
- Kernel for excel - Download - Backup and recovery
3 responses
From that description, it sounds like you are selecting more than you need, though you state that you are not. If not, how could it be pasted?
Can you post the lines of code that do the selecting and copying followed by the paste code?
Can you post the lines of code that do the selecting and copying followed by the paste code?
Columns("C:C").NumberFormat = "0000"
Range("A1:K" & end1).Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:= _
Range("A2"), Order2:=xlDescending, Key3:=Range("B2"), Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
For t = 2 To end1
Cells(t, 3) = CInt(Cells(t, 3))
Next t
For a = 2 To end1
If Cells(a, 3) <> Cells(a - 1, 3) Then
dealer = Cells(a, 3)
b = a + 11
r = a - 1
Set wk2 = Workbooks.Open("J:\Public\Library\Monthly\Dealer Centric Reports\Template.xls")
wk1.Activate
For n = a To b
If Cells(n, 3) = dealer Then
r = r + 1
End If
Next n
Rows(a & ":" & r).Copy
wk2.Activate
Range("A2").PasteSpecial
Range("A1:K" & end1).Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:= _
Range("A2"), Order2:=xlDescending, Key3:=Range("B2"), Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
For t = 2 To end1
Cells(t, 3) = CInt(Cells(t, 3))
Next t
For a = 2 To end1
If Cells(a, 3) <> Cells(a - 1, 3) Then
dealer = Cells(a, 3)
b = a + 11
r = a - 1
Set wk2 = Workbooks.Open("J:\Public\Library\Monthly\Dealer Centric Reports\Template.xls")
wk1.Activate
For n = a To b
If Cells(n, 3) = dealer Then
r = r + 1
End If
Next n
Rows(a & ":" & r).Copy
wk2.Activate
Range("A2").PasteSpecial
RayH
Posts
122
Registration date
Tuesday August 31, 2010
Status
Contributor
Last seen
June 20, 2016
26
Sep 2, 2010 at 07:01 PM
Sep 2, 2010 at 07:01 PM
"I am able to copy and paste the chunk I need but then below that chunk it keeps all of the other data"
Sorry, I may have mis-understood what you are trying to achieve. The new file already exists, does it contain data already or is it blank?
Is the data it is keeping in the new file? If so, blank it out first.
Sorry, I may have mis-understood what you are trying to achieve. The new file already exists, does it contain data already or is it blank?
Is the data it is keeping in the new file? If so, blank it out first.