Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35
Default Populating a form

I have created a form in excel and an address book on a separate worksheet.
The form is a basic contract for advertising and I have a field for contract
number and then fields for the name and address of the company that contract
number belongs to. I want to be able to say "if the contract number is "x,"
populate the name and address fields with the corresponding information from
the name and address list on the second worksheet." I have tried all sorts
of tricks, but nothing is working. Any thoughts? Thank you so much.
--
Deborah
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 345
Default Populating a form

Dave Peterson came up with this solution in may 2005 - Maybe it will work for
you:

If you lay out your data in rows (going across), you could use column A as
an indicator with your x. If column A is empty, then skip that row. If it's got something in it, then process it.

Option Explicit
Sub testme()

Dim fWks As Worksheet
Dim tWks As Worksheet

Dim fCol As Variant
Dim tAddr As Variant

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim iCtr As Long

fCol = Array("b", "c", "e") 'd skipped as an example
tAddr = Array("b12", "c19", "x45")

If UBound(fCol) < UBound(tAddr) Then
MsgBox "design error--not same number of columns/cells)"
End If

Set fWks = Worksheets("Input")
Set tWks = Worksheets("Master")

With fWks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow
If IsEmpty(.Cells(iRow, "A")) Then
'skip this row
Else
For iCtr = LBound(fCol) To UBound(fCol)
tWks.Range(tAddr(iCtr)).Value _
= .Cells(iRow, fCol(iCtr)).Value
Next iCtr
tWks.PrintOut preview:=True
End If
Next iRow
End With

End Sub

You can modify these two lines:

fCol = Array("b", "c", "e") 'd skipped as an example
tAddr = Array("b12", "c19", "x45")

To map the column to the address.

And I used these two lines to specify the worksheet names.

Set fWks = Worksheets("Input")
Set tWks = Worksheets("Master")


Hope this helps


"Deborah" wrote:

I have created a form in excel and an address book on a separate worksheet.
The form is a basic contract for advertising and I have a field for contract
number and then fields for the name and address of the company that contract
number belongs to. I want to be able to say "if the contract number is "x,"
populate the name and address fields with the corresponding information from
the name and address list on the second worksheet." I have tried all sorts
of tricks, but nothing is working. Any thoughts? Thank you so much.
--
Deborah

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Populating a form

And Debra Dalgleish added some stuff he
http://contextures.com/xlForm03.html
and maybe he
http://contextures.com/xlForm02.html


Ron@Buy wrote:

Dave Peterson came up with this solution in may 2005 - Maybe it will work for
you:

If you lay out your data in rows (going across), you could use column A as
an indicator with your x. If column A is empty, then skip that row. If it's got something in it, then process it.

Option Explicit
Sub testme()

Dim fWks As Worksheet
Dim tWks As Worksheet

Dim fCol As Variant
Dim tAddr As Variant

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim iCtr As Long

fCol = Array("b", "c", "e") 'd skipped as an example
tAddr = Array("b12", "c19", "x45")

If UBound(fCol) < UBound(tAddr) Then
MsgBox "design error--not same number of columns/cells)"
End If

Set fWks = Worksheets("Input")
Set tWks = Worksheets("Master")

With fWks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow
If IsEmpty(.Cells(iRow, "A")) Then
'skip this row
Else
For iCtr = LBound(fCol) To UBound(fCol)
tWks.Range(tAddr(iCtr)).Value _
= .Cells(iRow, fCol(iCtr)).Value
Next iCtr
tWks.PrintOut preview:=True
End If
Next iRow
End With

End Sub

You can modify these two lines:

fCol = Array("b", "c", "e") 'd skipped as an example
tAddr = Array("b12", "c19", "x45")

To map the column to the address.

And I used these two lines to specify the worksheet names.

Set fWks = Worksheets("Input")
Set tWks = Worksheets("Master")


Hope this helps

"Deborah" wrote:

I have created a form in excel and an address book on a separate worksheet.
The form is a basic contract for advertising and I have a field for contract
number and then fields for the name and address of the company that contract
number belongs to. I want to be able to say "if the contract number is "x,"
populate the name and address fields with the corresponding information from
the name and address list on the second worksheet." I have tried all sorts
of tricks, but nothing is working. Any thoughts? Thank you so much.
--
Deborah


--

Dave Peterson
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
Using a template form, advance a form number everytime you open ShoDan Excel Discussion (Misc queries) 1 January 31st 08 01:34 PM
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
Can a form made in Excel 2002 be converted into a fillable form? Paraclete Excel Discussion (Misc queries) 1 February 20th 07 09:20 PM
How do I put my information form Excel into a Word Merge Form? Jackie Excel Discussion (Misc queries) 2 March 16th 06 08:16 PM
how can I make a form number change everytime the form is opened babydumplingspita Excel Worksheet Functions 1 October 10th 05 07:58 PM


All times are GMT +1. The time now is 04:53 AM.

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"