473,387 Members | 1,493 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,387 software developers and data experts.

Delete Excel Sheet Before Import to Access

283 100+
Hello,

I'm trying to write a small VBA code that will delete the first sheet (named Sheet1) from an Excel workbook before I import it. I have the import code working just fine but the information I need is on the second sheet and I cant figure out how to either reference the second sheet or just delete the first sheet.

Appreciate the help,

Slen :D
Jan 3 '12 #1

✓ answered by Mariostg

NeoPa:
The Help system wasn't too much help with this Slenish, but I managed to find that the Range parameter can take a range string value which includes a reference to the actual worksheet too. Say your data is held in a worksheet called [Sheet3], then the value for Range would be something like "Sheet3!A1:V99".
You don't need to delete any sheets. for the Range argument for the transferspreadsheet function, put a "!" at the end of the sheet name to import "Sheet1!". Works in Access 2003.

9 1959
NeoPa
32,556 Expert Mod 16PB
The Help system wasn't too much help with this Slenish, but I managed to find that the Range parameter can take a range string value which includes a reference to the actual worksheet too. Say your data is held in a worksheet called [Sheet3], then the value for Range would be something like "Sheet3!A1:V99".
Jan 3 '12 #2
slenish
283 100+
Hi NeoPa,

hmm I have tried the Range command but that has been getting me no where. Do you want me to post what I have? Maybe we can figure out where to put something in to the code I already have.

I can make it loop threw the sheets to each one but the problem is that sheet 1 and sheet 2 have the same headers so it pulls in information for both sheets when I only need the second one. That is why i want to just delete the first one.

I'll put together a test db and post it.
Jan 3 '12 #3
NeoPa
32,556 Expert Mod 16PB
A better idea would be to post the code you've tried in a normal post, but if you want to attach a ZIP file with your database and spreadsheet too, then that won't be a problem. See Attach Database (or other work).
Jan 3 '12 #4
slenish
283 100+
Hi NeoPa,

Sorry it took me a little bit to get this set up. I kept messing with it more and I actually got the delete feature to work, but there is still a problem. It opens and asks you if you want to delete the sheet. Was wondering if you know anyway to make it just delete with out asking?

Appreciate you taking a look at this

Slen :D
Attached Files
File Type: zip Test DB.zip (43.8 KB, 98 views)
Jan 4 '12 #5
Mariostg
332 100+
NeoPa:
The Help system wasn't too much help with this Slenish, but I managed to find that the Range parameter can take a range string value which includes a reference to the actual worksheet too. Say your data is held in a worksheet called [Sheet3], then the value for Range would be something like "Sheet3!A1:V99".
You don't need to delete any sheets. for the Range argument for the transferspreadsheet function, put a "!" at the end of the sheet name to import "Sheet1!". Works in Access 2003.
Jan 4 '12 #6
NeoPa
32,556 Expert Mod 16PB
Slenish:
Appreciate you taking a look at this
You seem to have misunderstood my earlier post where I explained you should post the code that you've tried or are working on, with a clear description of the problems involved with the code. When I have some code to work with I may look for more detail in the attachment, but I never look for the question in attachments. That has never struck me as a sensible way to approach things.
Jan 4 '12 #7
NeoPa
32,556 Expert Mod 16PB
Mario has kindly filled in the gap from my post #2, where I was unable to work out (guess - as the Help System had no info on it) the syntax of the Range parameter in order to tell it to use a particular sheet alone (IE. without specifying a range within the sheet as well).
Jan 4 '12 #8
slenish
283 100+
Appreciate the help on this I got it working for what I needed it to do.

Sorry I forgot the post the code in question to go along with the attachment. I'll make sure to do that going forward.

Thanks again :D
Jan 4 '12 #9
NeoPa
32,556 Expert Mod 16PB
Good enough Slenish. It was an interesting question, and I learned something while looking at it. You might want to select one of the posts that provided the answer for you. In fact, I'll change post #6 to include a quote of post #2 then you can select it (post #6) as Best Answer and it will reflect both parts of the answer for anyone else looking for help on any similar problem.
Jan 5 '12 #10

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

Similar topics

9
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
5
Zerin
by: Zerin | last post by:
I have to develop a database in access and VB 2005 will be in front view. Some results are send to this software in .csv format and .jpg format and I have to store it in the database.Now, for .csv...
0
by: jj | last post by:
I'm going mad! I'm exporting a query to excel, and afterwards calculating a field, and a sum of all fields in Excel from a sub procedure in a Module in Access. First I used ...
1
by: gpgp | last post by:
I have a excel macro like this: 1. Range("C2").Select Range(Selection, Selection.End(xlDown)).Select Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _ ...
2
by: saddist | last post by:
Hello, I have and excel sheet with fields: Name | Surname | Dept. When I execute the following code, it imports 16 empty rows + filled ones DoCmd.TransferSpreadsheet acImport = 0,...
3
by: inepu | last post by:
I have some excel sheets that I would like to manage in access. I've created the access tables and relationships; the excel sheet is only one table and with duplicate data, I'd like to make sure that...
0
by: satenova | last post by:
Hello Friends, I am newbie when it comes to vb.net and i need to import excel sheet into access db using vb.net application. Here is the code i use for now to upload excel sheet and it works...
0
by: sadhana86 | last post by:
Hi There, I have a excel sheet which is a report, which I run in a SAP application. Now I have so many fields, below is the example of the report: User_iD Action Info_type Sub_Info_Type ...
3
by: Keith Faulkner | last post by:
I am trying to add a logo from a bitmap file to an Excel report which is created using MS Access 2010. This code works, but it inserts the bitmap as a linked file. So when I view the excel file on...
2
by: Sally O Askar | last post by:
Please help me, I am designing a small application that takes an excel sheet , this sheet contains my students marks inside a table named grade1. I want to import this table to my access table I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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,...

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.