Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default multiple updates to database

Mike-thank you so much, it works flawlessly!
have a great rest of your week

-mae

"Mike H." wrote:

Put this code on a button anywhere and it should do the trick.

Private Sub CommandButton1_Click()
Dim X As Long
Dim Fnd As Long
Dim DataArray(5000, 2) As Variant

'if tempsheet is on another workbook then this line too:
windows("tempsheet").activate
Sheet("Tempsheet").Select
X = 1
Do While True
If Cells(X, 1).Value = Empty Then Exit Do
Fnd = Fnd + 1
DataArray(Fnd, 1) = Cells(X, 1).Value
DataArray(Fnd, 2) = Cells(X, 2).Value
X = X + 1
Loop
'now we have an array, dataarray, which has all the cow #'s (From Column 1)
and all the vaccine dates from col 2
'if database is in a different workbook:
Windows("database.xls").Activate

Sheet("database").Select
X = 1
Do While True
If Cells(X, 2).Value = Empty Then Exit Do
For y = 1 To Fnd
If DataArray(y, 1) = Cells(X, 2).Value Then
If Cells(X, 3).Value = Empty Then
Cells(X, 3).Value = DataArray(y, 2)
Exit For
ElseIf Cells(X, 4).Value = Empty Then
Cells(X, 4).Value = DataArray(y, 2)
Exit For
ElseIf Cells(X, 5).Value = Empty Then
Cells(X, 5).Value = DataArray(y, 2)
Exit For
ElseIf Cells(X, 6).Value = Empty Then
Cells(X, 6).Value = DataArray(y, 2)
Exit For
ElseIf Cells(X, 7).Value = Empty Then
Cells(X, 7).Value = DataArray(y, 2)
Exit For
End If
End If
Next
X = X + 1
Loop






End Sub

Reply
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
Database updates pfdubz Excel Discussion (Misc queries) 2 September 16th 09 11:00 PM
Mulitple updates in database M.Desmond Excel Programming 5 October 10th 08 08:52 PM
Excel Multiple sheet updates Liz Excel Worksheet Functions 1 September 26th 08 08:50 PM
Set up database that updates automatically Qty's entered jcheko Excel Worksheet Functions 0 March 4th 08 07:09 PM
Drawing driven database updates Kennard Excel Discussion (Misc queries) 1 February 13th 06 03:40 AM


All times are GMT +1. The time now is 11:15 AM.

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

About Us

"It's about Microsoft Excel"