473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with Creating/Executing Excel Macro

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_ID
Target2=FAXDIDNUM
Target3=REMOTEID
Target4=SNED_TIME
Target5=FAX_STATUS
Target6=NUMPAGES
Target7FAXDATE
Target8=FAXTIME
ActiveSheet.Range("A1").Select THIS IS THE ROW WITH THE ERROR
Do Until ActiveCell=""
If ActiveCell.Value<>Target1 and ActiveCell.Value<>Target2 and ActiveCell.Value<>Target3 and ActiveCell.Value<>Target4 and ActiveCell.Value<>Target5 and ActiveCell.Value<>Target6 and ActiveCell.Value<>Target7 and ActiveCell.Value<>Target8 Then
Active.Cell.EntireColumn.Delete
Else
ActiveCell.Offset(0,1).Activate
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 2227
Dököll
2,364 Expert 2GB
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
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...
5
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...
8
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...
0
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...
1
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) ,...
4
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...
1
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...
0
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...
1
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.