Values from Excel-To Access-Then to Excel again

ECEstudent

Registered User.
Local time
Today, 15:01
Joined
Jun 12, 2013
Messages
153
Does anyone know how to take values from an excel file, use them in a form in a database, and then go back to that excel file and add the new values to another place in the excel file? Do the value places have to be evenly spaced out?

I already know how to take columns from an excel file and use them in my code. But these values I am trying to use are kind of scattered around the excel sheet. The values I am extracting from the database are in a specific column and the values I am adding to the excel sheet are in a different column. Just the rows between these values aren't evenly spaced out. Any help appreciated.
 
It is possible to navigate round an excel worksheet looking for values which may be scattered about.
Just use the Offset function which allows you to move up/down, left/right. If you put it inside a for loop, you can examine each cell, if it contains a value, do something else move to the next. If you want to scan several columns, you can use 2 nested for loops.
For example if you want to scan all the cells in columns A-F down to row 1000

Code:
Dim i, j As Integer
Range("A1").Select
For i = 1 to 6 'this is the outer loop to navigate the columns
    For j = 1 to 1000 'this is the inner loop to navigate the rows
        If Activecell.Value = vbNullString Then
            'do nothing
            Else
                 'code to use the value in your database
        End If
        Activecell.Offset(1,0).Select 'move down one cell
    Next j
    Activecell.Offset(-1000,1).Select 'go back to the top but one column across
Next i

David
 
Thanks for the reply! I just found out that the rows that I would need to select the values from are called 'CAGE ASSY,CAVIII,2' AND 'PLUG/STEM,CAV III' AND 'SEAT RING'.

As for the locations that I would need to enter the resulting values of my code in, they go in the same row that I selected the values from ('CAGE ASSY,CAVIII,2' OR 'PLUG/STEM,CAV III' OR 'SEAT RING') and the column is called 'Unit Sales 10 yrs (Installed Base)'

Is there a way to simply the code so it would only receive/enter the values from/to these columns and rows?

Thank you so much!!
 
Hi,

I went to the link that you gave me Mihail, but I still don't quite understand what to do...
I've been working on other parts of my code in the meantime and now I'm done with the whole thing except this transfer part.
Can someone please help? I would realllllllly appreciate it. I have no idea how to do this thing. Never really worked with Excel much in order to link it with access.

Laura
 

Users who are viewing this thread

Back
Top Bottom