473,776 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing dynamic range into Access

I have a dynamic range that I would like to use as a linked table into
Access. The problem is that Access doesn't seem to want to to
recognize the dynamic range when you click on "show named ranges" in
the Link Spreadsheet wizard. The reason I want to use a dynamic range
is because when the data in my excel spreadsheet changes the linked
table will import blank rows that were previously used from the bottom
of the spreadsheet. I can't figure out how to get rid of these extra
rows without using an additional query to filter on the blank cells.

Any ideas?

Thanks,
Brian

Sep 5 '07 #1
4 5466
"Bongard" <b.*******@gmai l.comwrote in message
news:11******** *************@d 55g2000hsg.goog legroups.com...
>I have a dynamic range that I would like to use as a linked table into
Access. The problem is that Access doesn't seem to want to to
recognize the dynamic range when you click on "show named ranges" in
the Link Spreadsheet wizard. The reason I want to use a dynamic range
is because when the data in my excel spreadsheet changes the linked
table will import blank rows that were previously used from the bottom
of the spreadsheet. I can't figure out how to get rid of these extra
rows without using an additional query to filter on the blank cells.

Any ideas?

Thanks,
Brian
In Excel, select all the cells you wish in your 'table', then name the range
by typing it into the cell reference box (it will currently be showing D16
or something). Press Return - this is important because Excel will 'forget'
your name if you don't.

Now you can link to the range from Access.

Sep 5 '07 #2
Thanks for the response Stuart but this is not going to work. I have
created a dynamic range (expands and contracts depending on data size)
to allow for the constant changing of data within the Excel file. If I
just use a typical named range it will not change size to include or
exclude cells as necessary.

Sep 5 '07 #3
Bongard wrote:
Thanks for the response Stuart but this is not going to work. I have
created a dynamic range (expands and contracts depending on data size)
to allow for the constant changing of data within the Excel file. If I
just use a typical named range it will not change size to include or
exclude cells as necessary.
Maybe ask in a microsoft.publi c.excel newsgroup for some vba code to
define dynamic ranges.

You may find some things on dynamic ranges in google, such as
http://groups.google.com/group/micro...3035e1d472421e

Maybe there's some answers at google or the Excel newsgroups.

Would it not be possible to create a named range on the fly and then do
the link? Perhaps delete a named range, recreate dynamic, save the
coordinates as a new range, then import?

Sep 5 '07 #4
Hi Bongard,

This is a problem that I have never found an exact solution to, but I
can give you a pragmatic one. If your dynamic named range is not
expanding to extra columns then this will work:

1/ Select all the columns in Excel (eg: A B C D E.....)

2/ Type in a name for the 'fixed' range. This is going to refer to the
same cells as the dynamic at the same time that the dynamic range is
referring to them.

3/ Using ADO to connect to the spreadsheet, you can then import the
data into a local table as follows.....

Dim cnn As ADODB.Connectio n
Set cnn = New ADODB.Connectio n
With cnn
.Provider = "Microsoft.Jet. OLEDB.4.0"
.ConnectionStri ng = "Data Source = " & FileName & "; Extended
Properties = Excel 8.0;"
.Open
End With

Dim rs as ADODB.Recordset
Set rs = New ADODB.Recordset
SQL = "select * from [" & NamedRangeName & "] where ColumnName <>
null"

With rs
.CursorLocation = adUseClient
.Open SQL, cnn, adOpenForwardOn ly, adLockReadOnly, adCmdText
.ActiveConnecti on = Nothing
End With

cnn.Close
Set cnn = Nothing

Dim db As DAO.Database
Set db = CurrentDb

Dim DRS As DAO.Recordset
Set DRS = db.OpenRecordse t("RawImport" )

Dim exists As Boolean
exists = False

Dim adoFLD As ADODB.Field
Dim daoFLD As DAO.Field

Do Until rs.EOF
DRS.AddNew
For Each adoFLD In rs.Fields
For Each daoFLD In DRS.Fields
If adoFLD.Name = daoFLD.Name Then
DRS(daoFLD.Name ) = rs.Fields.Item( adoFLD.Name).Va lue
End If
Next
Next
DRS.Update
rs.MoveNext
Loop

You can obviously set up some routines in there to check the records
in the 'rawimport' table to see if the records already exists. Once
the data is in a local table you can pretty much do with it what you
like.

The key here is that the number of columns in the source Excel
spreadsheet cant change. If you add a new column to the spreadsheet
then there must be a matching field added to the access table to
receive the data or it will be missed. You shouldnt get any blank
records here because the SQL select statement used to rip the data
from the spreadsheets named range specifies a column of your choosing
to not be null, so a blank wont be imported. Lastly, make sure your
data types match and that the field in Access has enough size to
accomodate the incoming Excel data - really watch for this with text
fields.

I hope that this helps you out.

Cheers

The Frog

Sep 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
17673
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
2
2494
by: Don W. Reynolds | last post by:
Hi All, I am sent an excel spreadsheet on a daily basis. Sometimes it contains 10 rows; sometimes it contains over 5000 rows. I copy this spreadsheet into another spreadsheet and verify the format of the data (some data is missing, which I can add, some 15 digit data needs to be text rather than numeric, sometimes the incoming numbers are not consistent and need leading digits, etc.). I then import this data (from the second...
9
3920
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. There is no further explanation. What are the kinds of things that make this happen? Thanks from an obvious rookie. Gordon
7
1645
by: robert d via AccessMonster.com | last post by:
I just imported 62000 rows twice from Excel. In my import routine, I create a holding table and then validate the data prior to committing to the main table. The holding table is created in the front end. All other tables are in the backend. After the import, response from the application was extremely slow and it appeared to have frozen. It occurred to me that database bloat might be the problem. So I used Ctrl-Alt-Del to close the...
0
2913
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
3
5327
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file has no problems, I've done it manually with the Import Spreadsheet wizard. The worksheet has 43 rows, and I import a named range defined as "=Sheet1!$C:$E". The import works, but I get a table with 64K rows, all but 43 being blank!
5
1594
by: Grubsy4u | last post by:
Hi all, My name is Daniel Iam trying to learn visual basic and I have been having problems building a marco in Access 2003 that will allow me to extract data from my Excel 2003 spreadsheet into my Access table (fields have the same name, i just need to change the data). The data in the spreadsheet is huge with 32 columns and about 7000 rows. I have tried to wirte code but i keep getting error messages. Maybe i need to start with something...
2
2249
anoble1
by: anoble1 | last post by:
I have a button in my database that when you hit tit, it imports just 1 excel sheet and puts it in a table. Works great. I am wanting to grab 4 more excel sheets from different locations and store them in the same table. Here is my code. I pasted my code in a .txt file so it can be easily read. Thanks!! Private Sub Command35_Click() On Error GoTo Err_Command0_Click Dim appExcel As Object Dim workBook As Object Dim workSheet...
0
9459
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
10285
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9921
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
8949
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...
0
6721
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5489
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3620
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2857
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.