LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default database in excel problem

Hi experts,

I have 2 sheets:

1. Sheet("deelnemers") for the data used 'deelnemers means employees
the data is stored in "B3:F992", depending on the number of employees,
so 5 items per employee
2. Sheet("dbasedlnrs") to store the data from sheet("deelnemers in")
the data is stored in range("A:F") where a is the company name

there is a company name to recognise the employees from. This company name is
on
sheet("staffelberekening").range("J3")

To retrieve the data i use a user inputform where the user can input the
companyname (CoName)
i use the following code to then retrieve the data

Sub CopyDBToData(CoName As String)
Sheets("deelnemers").Select
' clear any existing employees
With Sheets("deelnemers")
..Range("B3", .Range("F" & Rows.Count).End(xlUp)).ClearContents
End With
' code to get the employees from the database
With Sheets("dbasedlnrs")
Set dbColA = .Range("A1", .Range("A" & Rows.Count).End(xlUp))
Set FirstdbCell = dbColA.Find(What:=CoName, LookAt:=xlWhole)
Set LastdbCell = dbColA.Find(What:=CoName, LookAt:=xlWhole,
SearchDirection:=xlPrevious, searchOrder:=xlByColumns)
.Range(FirstdbCell, LastdbCell).Offset(0, 1).Resize(, 3).Copy Sheets
("deelnemers").Range("B3")
Sheets("staffelberekening").Range("J3") = CoName
End With
End Sub

When i run the code the only error message i get is on the line
..Range(firstdbCell.....
Furthermore the range A1:F2 is cleared from the 'deelnemers' sheet and that
is not what i want...

I think the Offset or resize statement is incorrect but i cannot seem to
solve it

Can anyone help me get the right code please?
thanks,
Pierre

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200511/1
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delicate Excel-database problem khers Excel Discussion (Misc queries) 2 August 12th 09 10:55 PM
problem vba dialoguebox and database in excel Jean-Pierre Excel Programming 1 September 28th 05 04:18 PM
Problem with the import of a database table into Excel 2003. LWhite Excel Programming 3 May 13th 05 08:13 PM
Excel function to search and access database problem Brian K. Sheperd Excel Programming 0 April 20th 05 08:42 PM
MS Access Database Connection problem in Excel XP 2002 Sarwat Malik Excel Programming 1 July 16th 04 01:22 PM


All times are GMT +1. The time now is 03:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"