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: 586
Default Load Userform Control Values from Worksheet

If I double click a cell my macro takes the target value and finds what
column the target value is in. I then scan down that column and assign all
my userform controls there values. Is there a cleaner way of doing this?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim myRef As Variant
Dim aryFormCtrls As Variant
Dim i As Long

' loads userform with stored data associated with reference number on
quote sheet
Select Case Left(Target, 2)

Case Is = "Plastic Faces"

Case Is = "Alum Faces"

Set wksItem = Sheets("Alum Faces")

' return column number of reference number in item data sheet, error
occurs if not found
dblColNumber = WorksheetFunction.Match(Target, wksItem.Rows("1:1"), 0)

With frmAluminumFaces
.lblRefNumber = Target
.tbxHeightFt = wksItem.Cells(1, dblColNumber).Offset(1)
.tbxHeightIns = wksItem.Cells(1, dblColNumber).Offset(2)
.tbxWidthFt = wksItem.Cells(1, dblColNumber).Offset(3)
.tbxWidthIns = wksItem.Cells(1, dblColNumber).Offset(4)
.cboFaceMaterial = wksItem.Cells(1, dblColNumber).Offset(5)
.cboMounting = wksItem.Cells(1, dblColNumber).Offset(6)
.cboFaceShape = wksItem.Cells(1, dblColNumber).Offset(7)
'paint
.chkPaint = wksItem.Cells(1, dblColNumber).Offset(8)
.chkTextured = wksItem.Cells(1, dblColNumber).Offset(9)
.tbxColorsP = wksItem.Cells(1, dblColNumber).Offset(10)
.spbColorsP = wksItem.Cells(1, dblColNumber).Offset(11)
.optSimpleP = wksItem.Cells(1, dblColNumber).Offset(12)
.optComplexP = wksItem.Cells(1, dblColNumber).Offset(13)
.cboAreaP1 = wksItem.Cells(1, dblColNumber).Offset(14)
.tbxColorP1 = wksItem.Cells(1, dblColNumber).Offset(15)
.mpgPaint.Pages(0).Visible = wksItem.Cells(1,
dblColNumber).Offset(16)
.cboAreaP2 = wksItem.Cells(1, dblColNumber).Offset(17)
.tbxColorP2 = wksItem.Cells(1, dblColNumber).Offset(18)
.mpgPaint.Pages(1).Visible = wksItem.Cells(1,
dblColNumber).Offset(19)
.cboAreaP3 = wksItem.Cells(1, dblColNumber).Offset(20)
.tbxColorP3 = wksItem.Cells(1, dblColNumber).Offset(21)
.mpgPaint.Pages(2).Visible = wksItem.Cells(1,
dblColNumber).Offset(22)
.cboAreaP4 = wksItem.Cells(1, dblColNumber).Offset(23)
.tbxColorP4 = wksItem.Cells(1, dblColNumber).Offset(24)
.mpgPaint.Pages(3).Visible = wksItem.Cells(1,
dblColNumber).Offset(25)
'vinyl
.chkVinyl = wksItem.Cells(1, dblColNumber).Offset(26)
.tbxColorsV = wksItem.Cells(1, dblColNumber).Offset(27)
.spbColorsV = wksItem.Cells(1, dblColNumber).Offset(28)
.optSimpleV = wksItem.Cells(1, dblColNumber).Offset(29)
.optComplexV = wksItem.Cells(1, dblColNumber).Offset(30)
.cboAreaV1 = wksItem.Cells(1, dblColNumber).Offset(31)
.tbxColorV1 = wksItem.Cells(1, dblColNumber).Offset(32)
.mpgVinyl.Pages(0).Visible = wksItem.Cells(1,
dblColNumber).Offset(33)
.cboAreaV2 = wksItem.Cells(1, dblColNumber).Offset(34)
.tbxColorV2 = wksItem.Cells(1, dblColNumber).Offset(35)
.mpgVinyl.Pages(1).Visible = wksItem.Cells(1,
dblColNumber).Offset(36)
.cboAreaV3 = wksItem.Cells(1, dblColNumber).Offset(37)
.tbxColorV3 = wksItem.Cells(1, dblColNumber).Offset(38)
.mpgVinyl.Pages(2).Visible = wksItem.Cells(1,
dblColNumber).Offset(39)
.cboAreaV4 = wksItem.Cells(1, dblColNumber).Offset(40)
.tbxColorV4 = wksItem.Cells(1, dblColNumber).Offset(41)
.mpgVinyl.Pages(3).Visible = wksItem.Cells(1,
dblColNumber).Offset(42)
'digital print
.chkDigitalPrint = wksItem.Cells(1, dblColNumber).Offset(43)
.cboAreaD = wksItem.Cells(1, dblColNumber).Offset(44)
'routing
.chkRouted = wksItem.Cells(1, dblColNumber).Offset(45)
.cboAreaR = wksItem.Cells(1, dblColNumber).Offset(46)
.cboBackingDeco = wksItem.Cells(1, dblColNumber).Offset(47)

.tbxCustomItem1 = wksItem.Cells(1, dblColNumber).Offset(48)
.tbxCustomItem1Cost = wksItem.Cells(1, dblColNumber).Offset(49)
.tbxCustomItem2 = wksItem.Cells(1, dblColNumber).Offset(50)
.tbxCustomItem2Cost = wksItem.Cells(1, dblColNumber).Offset(51)
.chkCrate = wksItem.Cells(1, dblColNumber).Offset(52)
.tbxCrateH = wksItem.Cells(1, dblColNumber).Offset(53)
.tbxCrateW = wksItem.Cells(1, dblColNumber).Offset(54)
.tbxCrateD = wksItem.Cells(1, dblColNumber).Offset(55)
.tbxCrateQty = wksItem.Cells(1, dblColNumber).Offset(56)
.tbxCrateCost = wksItem.Cells(1, dblColNumber).Offset(57)
.tbxQuantity = wksItem.Cells(1, dblColNumber).Offset(58)
.tbxDiscount = wksItem.Cells(1, dblColNumber).Offset(59)
.tbxComments = wksItem.Cells(1, dblColNumber).Offset(60)
End With

Call frmAluminumFaces.cmbCalculate_Click
frmAluminumFaces.Show

End Sub
--
Cheers,
Ryan
 
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
Load Userform Values from Sheet with Array & For...Loop RyanH Excel Programming 0 November 12th 08 07:38 PM
Load Pictures in UserForm from Worksheet Shazi Excel Programming 3 July 18th 08 08:52 PM
Userform with spreadsheet control will not load Jeff Kraft Excel Programming 1 August 21st 06 03:26 PM
Can you load part of a worksheet into a userform wAyne Excel Programming 1 April 9th 06 10:41 PM
Can you load part of a worksheet into a userform Tom Ogilvy Excel Programming 0 April 7th 06 06:30 PM


All times are GMT +1. The time now is 02:33 PM.

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"