Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill a userform with information that is in a spreadsheet

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
GB
I have 3 excel documents that i will be populating from one single userform called userform2. Main.xls will have all of the information from the userform2 in, then depending on one of the options on the userform certain information will be pased to either extratime.xls or extrasupport.xls

When main.xls opens, i have userform1 visible and excel is hidden. the user is given the option to add data to the spreadsheet, or to just view the spreadsheet. if the user clicks view then the userform closes. if they click add then userform2 pops up and they fill in the data. when they click save it populates the relevant workbooks. I want to put a 3rd button on userform1 so that information can be amended, then updated in the relevant workbooks so that the user is not having to open up 2 workbooks as some data is shared accross the 2.

So i guess basically i am wanting to search my workbook, then populate the result back in to the userform so that i can make amendments then repopulate the correct workbooks.

I know what i want...just don't know how to do it, i am learning vba bit by bit as i go along so anyhelp would be appreciated.

I am using Excel 2003 and i know a database might be a better solution but we are not allowed to use one in our company as they offer no support for it
 



Hi,

I would use the Find method to locate a row of data. Then you just read across the row.

Build a cross reference of column heading and control name, assuming that each sheet is stuctured the same.
Code:
sub ReturnRowItems(ws as worksheet, SrchVal)
  dim rFound as range, c as range
  
  set rfound = ws.cells.find(SrchVal)

  if not rfound is nothing then
     for each c in intersect(rfound.entirerow, ws.usedrange)
        yourform.controls(cntlname).text = c.value
     next
  else
    'some appropriate message
  end if
end sub
I'll leave it up to you to work on the cell to control referencing.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top