Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop lcd malware memory modem monitor motherboard network printer problem ram registry router slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Simple Copy & PasteSpecial Process

Reply  
Thread Tools
gerry125's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Nov 2009
Experience: Intermediate
19-Nov-2009, 10:45 AM #1
Solved: Simple Copy & PasteSpecial Process
I'm trying to write a macro in Excel (Vista) to look in column "H" of one sheet and find all instances of an entry "20" and then select that row of data in columns a:g and copy it below the last line of data in a second sheet.

Should be very easy - but I'm getting nowhere. So for any help I will be very grateful.

Gerry125

Last edited by gerry125; 19-Nov-2009 at 10:54 AM..
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
19-Nov-2009, 11:19 AM #2
Welcome to the forum Gerry125.

try this...

Code:
Sub Macro9()
'
Dim X As Long, DRw As Long
Dim DSheet As Worksheet, PSheet As Worksheet
Set DSheet = Sheets("Sheet1")
Set PSheet = Sheets("Sheet2")
DRw = DSheet.Cells(Rows.Count, "H").End(xlUp).Row
For X = DRw To 1 Step -1
If DSheet.Cells(X, "H") = "20" Then
DSheet.Range("A" & X & ":G" & X).Copy PSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
End If
Next
End Sub
HTH. Let us know if you need it tweeked.
gerry125's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Nov 2009
Experience: Intermediate
19-Nov-2009, 11:32 AM #3
Thanks very much - it very nearly works properly now. I've tweeked to fit my workbook so the code reads

Sub Macro9()
'
Dim X As Long, DRw As Long
Dim DSheet As Worksheet, PSheet As Worksheet
Set DSheet = Sheets("Future Transactions")
Set PSheet = Sheets("Current")
DRw = DSheet.Cells(Rows.Count, "H").End(xlUp).Row
For X = DRw To 1 Step -1
If DSheet.Cells(X, "H") = "20" Then
DSheet.Range("A" & X & ":E" & X).Copy PSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 1)
End If
Next
End Sub

Only problem is that there can be more than one row that is Flagged as 20 in column "H" and i want them all copied in.
Start position in "Current is Column B so I changed the paste location.

Rgds

Gerry
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
19-Nov-2009, 11:37 AM #4
Quote:
Only problem is that there can be more than one row that is Flagged as 20 in column "H" and i want them all copied in.
The code should work for ALL instances of "20" in column H of yiour "Future transactions" sheet. So i don;t understand what you mean by this, can you reframe the problem?
gerry125's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Nov 2009
Experience: Intermediate
19-Nov-2009, 11:46 AM #5
turbodante

Thanks for the continued interest..

It was me mucking about with your code. I changed the wrong part of the line -

DSheet.Range("A" & X & ":E" & X).Copy PSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 1).

Its all fixed now. Wonderful and thanks very much.

Gerry
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
19-Nov-2009, 12:04 PM #6
Great stuff. Please mark the top of the thread 'Solved' thanks. See you around.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:14 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.