Don Carlos
New Member
- Joined
- Feb 1, 2016
- Messages
- 5
(Excel 2010 - 32 Bit on Windows 7 Enterprise)
Hello,
I ask for your assistance with transferring data between an Excel Sheet and a userform. The userform is intended to both capture (write to an Excel sheet) and retrieve (from the same Excel sheet).
My problem is that, when I debug the code, cell reference contents will not consistently be captured into the textboxes. Usually, either the 'PrimaryRisk' is successful in reporting the information from the sheet and the 'SecondaryRisk' is not, or vice versa (in coming up Null).
Below is a sample of the code, which is purposely overly redundant to see if a method is consistently reliable. Typically, it will work or it won't for any of the methods in that set.
Notes:
1. I have tried to interchange between .value and .text without a change in results.
2. nSelectRecord is either 1 if not determined by the user or the record number selected by the user.
3. tTempText is usually successful in capturing the Excel sheet information, but is usually not successful in being written into the textbox.
Thank you in advance for your assistance.
Hello,
I ask for your assistance with transferring data between an Excel Sheet and a userform. The userform is intended to both capture (write to an Excel sheet) and retrieve (from the same Excel sheet).
My problem is that, when I debug the code, cell reference contents will not consistently be captured into the textboxes. Usually, either the 'PrimaryRisk' is successful in reporting the information from the sheet and the 'SecondaryRisk' is not, or vice versa (in coming up Null).
Below is a sample of the code, which is purposely overly redundant to see if a method is consistently reliable. Typically, it will work or it won't for any of the methods in that set.
Code:
'PrimaryRisk
With UserForm3.PrimaryRisk
.Text = Sheet4.Cells(nSelectedRecord + 1, 3)
.Value = Sheet4.Cells(nSelectedRecord + 1, 3)
End With
If UserForm3.PrimaryRisk.Text = "" Then
UserForm3.PrimaryRisk.Value = Sheet4.Cells(nSelectedRecord + 1, 3)
End If
If UserForm3.PrimaryRisk.Text = "" Then
tTempText = Sheet4.Cells.Cells(nSelectedRecord + 1, 3).Value
UserForm3.PrimaryRisk.Text = tTempText
End If
If UserForm3.PrimaryRisk.Text = "" Then
UserForm3.PrimaryRisk.Value = Sheet4.Cells(nSelectedRecord + 1, 3).Value
End If
UserForm3.PrimaryRiskText.Value = WorksheetFunction.VLookup(UserForm3.PrimaryRisk.Value, Range("RISKTABLE"), 2, False)
'SecondaryRisk (Optional)
If Sheet4.Cells(nSelectedRecord + 1, 4) = "" Or Sheet4.Cells(nSelectedRecord + 1, 4) = 0 Then
UserForm3.SecondaryRisk.Text = ""
UserForm3.SecondaryRiskText.Value = ""
Else
With UserForm3.SecondaryRisk
.Text = Sheet4.Cells(nSelectedRecord + 1, 4).Value
.Value = Sheet4.Cells(nSelectedRecord + 1, 4).Value
End With
UserForm3.SecondaryRisk.Value = Sheet4.Cells(nSelectedRecord + 1, 4)
If UserForm3.SecondaryRisk.Text = "" Then
tTempText = Sheet4.Cells.Cells(nSelectedRecord + 1, 3).Value
UserForm3.SecondaryRisk.Text = tTempText
End If
If UserForm3.SecondaryRisk.Text = "" Then
UserForm3.SecondaryRisk.Value = Sheet4.Cells(nSelectedRecord + 1, 3).Value
End If
UserForm3.SecondaryRiskText.Value = WorksheetFunction.VLookup(UserForm3.SecondaryRisk.Value, Range("RISKTABLE"), 2, False)
End If
Notes:
1. I have tried to interchange between .value and .text without a change in results.
2. nSelectRecord is either 1 if not determined by the user or the record number selected by the user.
3. tTempText is usually successful in capturing the Excel sheet information, but is usually not successful in being written into the textbox.
Thank you in advance for your assistance.