473,657 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with Creating/Executing Excel Macro

1 New Member
I have to automatically create some Excel Spreadsheets based on automatically generated .CSV files that are produced overnight. Each .CSV has several columns that need to be deleted. The same columns (both in location and name) are deleted each time. The macro checks for Column Headers/Names and if the value isn't equal to one of 8 specifc values, I want to delete the column. I am attempting to create a Macro that executes automatically when a file is opened in Excel. I have found the Workbook_Open area in the VB Editor within Excel and have created a Macro that will execute when a file is opened. The macro will run successfully standalone outside of the Workbook_Open function. Whenever I add the macro to the Workbook_Open I receive a very generic error: Run-time error '1004' Method "Range" of Object'_Global Failed.
Here is the way I am executing the code:
ThisWorkbook has
Private Sub Workbook_Open()
FaxFormat

Here is the FaxFormat Macro
Sub FaxFormat()
Target1=OWNER_I D
Target2=FAXDIDN UM
Target3=REMOTEI D
Target4=SNED_TI ME
Target5=FAX_STA TUS
Target6=NUMPAGE S
Target7FAXDATE
Target8=FAXTIME
ActiveSheet.Ran ge("A1").Selec t THIS IS THE ROW WITH THE ERROR
Do Until ActiveCell=""
If ActiveCell.Valu e<>Target1 and ActiveCell.Valu e<>Target2 and ActiveCell.Valu e<>Target3 and ActiveCell.Valu e<>Target4 and ActiveCell.Valu e<>Target5 and ActiveCell.Valu e<>Target6 and ActiveCell.Valu e<>Target7 and ActiveCell.Valu e<>Target8 Then
Active.Cell.Ent ireColumn.Delet e
Else
ActiveCell.Offs et(0,1).Activat e
End If
Loop

The rest of the macro sorts and sizes columns, save the file and closes the file.

I am confused as the macro runs fine in standalone mode. It only errors when attempting to Auto Launch it upon opening of a file.

Thanks for any assistance.
Nov 14 '08 #1
1 2250
Dököll
2,364 Recognized Expert Top Contributor
Hey there good buddy!

Sorry, you probably needed this right away. Most of us are are spread out all over the world; time diffrence and all, hope you understand...

That said, I am not skilled at Macros, but I reckon the Access forum may help you get an idea.

How about giving them a try, see what pops up:-)

In a bit!
Jan 1 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
17404
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed a database for her which is intended to make things a lot easier; however, I don't have a lot of experience with Access and I find that designing the reports in Access is tedious. I want to be able to print the reports (which are simply based on...
5
2252
by: lis0122 | last post by:
I'm a database marketing manager for a small non-profit. I created a query that prompts you for a company name and then pulls a list of all of our contacts in the database in that company. Our sales folks are always asking for company contact lists and I just plug it in to this query and send them the list in excel. I want to give them the capability of using this query themselves without going through me. But I want them to do this...
8
6547
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a macro. (I'll get to using VB later on). What I would like to do is import a single workbook w/three seperate worksheets into three seperate access tables AND truncate the time stamp that is used in the excell sheet via a macro.
0
1693
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a single worksheet into a dataset. I successfully built a dynamic datagrid. And I did successfully bind it to the dataset. Then I added the datagrid control to a PlaceHolder. The first worksheet displays beautifully. The next step is to allow...
1
2619
by: mark.heyden | last post by:
Hi Frends, I am facing problems while trying to export data into pipe format. In fact I am fetching records from mysql database and then trying to create a text file ( using pipe as delimeter) , intending to open in Excel. The data is been inserted from textarea fields, where the user can write text and may press enter key to format his text accordingly. Now when the data entered into the database it keeps some
4
7946
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair out after googling for the last 3 days. I have written a large python script which inside of it creates an Excel table, the name of this file and how many objects can change for each project i run.
1
1869
by: Praveen James | last post by:
Hi, when I execute a T-SQL command (which have IF Condition or CASE WHEN THEN statement) using excel macros I am getting a error "Item Not found in the collection.....". But the vba excel macro is executing and giving the proper result when I don't use IF or CASE statements in the SQL command. Because of this I am facing problem... Can anybody tell me how to overcome this.
0
1092
by: =?Utf-8?B?SmFj?= | last post by:
hi, I would like to create a Excel macro that can help me to create charts. First, I created the Excel macro as below:- Sub Macro1() Selection.CurrentRegion.Select ActiveSheet.Shapes.AddChart.Select ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$D$4") ActiveChart.ChartType = xlColumnClustered ActiveChart.ChartStyle = 4
1
2675
by: Teres | last post by:
Hello, I am trying to do an macro that go through all excel files in a folder, bring their name and copy their name (title) to an worksheet. I don't have a lot of experience with excel. Can somebody please help me? Thanks
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.