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 driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory monitor motherboard music network obp operating system printer problem ram registry router slow software sound 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: Excel 2003 VBA - Run time error 9

Reply  
Thread Tools
ktasker's Avatar
Junior Member with 7 posts.
 
Join Date: Oct 2009
Experience: Beginner
05-Oct-2009, 01:52 PM #1
Solved: Excel 2003 VBA - Run time error 9
Hey guys,
I have one worksheet called Consumption with a list of clients. I need to filter the data by building type and copy the data from this worksheet to a worksheet for each building type. The building types are in column E and the entries start at line 12. The different types possible are listed in column E above the entries. For this particular example I need the first one in E1. Here is the code I have in VBA

Sub PasteToCustSheet(OfficeBuildings)
Dim C As Range
Sheets("Consumption").Activate
For Each C In Range(Range("E12"), Range("A65536").End(xlUp))
If C.Value = Range("E1").Value Then
C.EntireRow.Copy
ActiveSheet.Paste ThisWorkbook.Sheets(C.Value).Range("a65536").End(xlUp).Offset(1, 0)
End If
Next
Application.CutCopyMode = False
End Sub

It keeps giving me a runtime error 9 and highlighting the first line but OfficeBuildings is the name of one of the sheets I need the information to go to. How do I fix this?
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
05-Oct-2009, 02:09 PM #2
Normally when you include something in the parentheses after the sub name you are receiving an argument from another procedure or routine. Since I don't see you using this received argument anywhere else in your routine why did you set it up this way?

Regards,
Rollin
ktasker's Avatar
Junior Member with 7 posts.
 
Join Date: Oct 2009
Experience: Beginner
05-Oct-2009, 02:14 PM #3
I actually got my friend to help me write the code since I have no experience in VBA, but he is out of town for the next two weeks so he can't help me out with any problems I have. Feel free to suggest another way to do it.
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
05-Oct-2009, 04:51 PM #4
Remove what is in the parentheses and try it again. If this does not solve your problem then please attach a sample workbook to your next post and I'll take a look at it and write all the code for you.

Regards,
Rollin
ktasker's Avatar
Junior Member with 7 posts.
 
Join Date: Oct 2009
Experience: Beginner
05-Oct-2009, 04:53 PM #5
I still get a runtime error 9 if I remove the stuff in the paranthesis
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
05-Oct-2009, 05:43 PM #6
Can you post your sample workbook with the code attached? If you prefer to email it directly to me you can send to rollin_again at hotmail dot com.

Regards,
Rollin
ktasker's Avatar
Junior Member with 7 posts.
 
Join Date: Oct 2009
Experience: Beginner
06-Oct-2009, 10:50 AM #7
I rewrote the program and now it works fine. Thanks for being willing to help out though.
Reply

Tags
excel, vba

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 11:09 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.