Hi guys,
I am new to vba and am trying to create a userform to return the wb temp from db temp and RH.
Table is setup as db temp in cells A2:A102, RH in cells B1:AT102
The following formula works in the spreadsheet
=VLOOKUP(CEILING(Q18,0.5),CIBSE_DATA!$A$2:$AT$102,MATCH(R18,CIBSE_DATA!$B$1:$AT$1,1)
Where Q18 is db temp, R18 is RH.
Userform has 3 TextBox named RATS (db temp), RARH (RH) and RAWBS (wb temp). I've got this far with the code but keep getting an error 2042 on the Application .Match line.
Private Sub RARH_AfterUpdate()
Dim XRange As Range
Set XRange = Worksheets("CIBSE_DATA").Range("A1:AT1")
x = Application.Match(RARH.Text, XRange, 0)
Dim YRange As Range
Set YRange = Worksheets("CIBSE_DATA").Range("A2:AT102")
y1 = Application.WorksheetFunction.Ceiling(RATS.Value, 0.5)
y = Application.WorksheetFunction.VLookup(y1, YRange, 1)
Worksheets("CIBSE_DATA").Activate
Set cl = Cells(y, x)
cl.Select
RAWBS = cl.Value
End Sub
Can anyone tell me where I'm going wrong or if I'm even on the right track, I'm sure there must be an easier way of doing this !
Cheers for the help.
I am new to vba and am trying to create a userform to return the wb temp from db temp and RH.
Table is setup as db temp in cells A2:A102, RH in cells B1:AT102
The following formula works in the spreadsheet
=VLOOKUP(CEILING(Q18,0.5),CIBSE_DATA!$A$2:$AT$102,MATCH(R18,CIBSE_DATA!$B$1:$AT$1,1)
Where Q18 is db temp, R18 is RH.
Userform has 3 TextBox named RATS (db temp), RARH (RH) and RAWBS (wb temp). I've got this far with the code but keep getting an error 2042 on the Application .Match line.
Private Sub RARH_AfterUpdate()
Dim XRange As Range
Set XRange = Worksheets("CIBSE_DATA").Range("A1:AT1")
x = Application.Match(RARH.Text, XRange, 0)
Dim YRange As Range
Set YRange = Worksheets("CIBSE_DATA").Range("A2:AT102")
y1 = Application.WorksheetFunction.Ceiling(RATS.Value, 0.5)
y = Application.WorksheetFunction.VLookup(y1, YRange, 1)
Worksheets("CIBSE_DATA").Activate
Set cl = Cells(y, x)
cl.Select
RAWBS = cl.Value
End Sub
Can anyone tell me where I'm going wrong or if I'm even on the right track, I'm sure there must be an easier way of doing this !
Cheers for the help.