Thread: Form Macro
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Form Macro

This sounds like a classic use of Excel's DataForm. Keep the database of
information on a hidden sheet and call the Dataform from another sheet, to
modify the database. What I have done is similar. I have several databases
on 1 sheet, so my code is geared for that.
With the Vendor data on sheet2 and that sheet tab named "Data" and the upper
left cell of your data at A1, scroll to the right using the horizontal
scroll bar, untill your data is off the screen (this is important to keep
your data from being visible behind the DataForm). Now hide that sheet. Put
the below code in a standard code module. On a visible sheet (Sheet1) create
a CommandButton, label it something like "Update Vendors" and assign this
macro to it.

Sub Vendors()
ws = ActiveSheet.Name 'Stores the current sheet you are on
Sheet2.Activate 'adjust to the sheet your database is on
Range("A1:G3").Select Adjust to select your first header & first row of
data
ActiveCell.CurrentRegion.Select 'selects to last row of data
Selection.Name = "Database" 'Do not change
ActiveSheet.Name = "Vendors" 'Do not change
ActiveSheet.ShowDataForm 'Do not change, code stops here until DataForm
is closed
ActiveSheet.Name = "DATA" 'Change to match name on sheet tab where data
is
Range("A1").Select 'resets cursor on database sheet for next time
Sheets(ws).Activate 'Selects the sheet you started from
End Sub

Cheers,
Mike F

"Dominic" wrote in message
...
Dear Advisers
I have a workbook with 2 sheets. One of the sheets is for
Vendors which has 7 Columns Heads for relevant vendor
details. The Other Sheet is bascially a lookup of the
Vendor Details and Additional Data.
I would like to do the following:
Create a Macro on the Other sheet that when it Runs, I can
input details in a Form which are relevant to the details
of the 7 Column Heads of the Vendor Sheet. Assuming that
the Vendor Sheet is Hidden.
Thank You in Advance for any assistance rendered.
regards
Dominic