ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textboxes (https://www.excelbanter.com/excel-programming/303381-textboxes.html)

Marcotte A

Textboxes
 
I have a userform with multiple (90) textboxes. The user enters data into some of them, and then that data is transferred to the spreadsheet. (The textboxes are not linked directly to cells). However, I do not want to transfer the data onto the spreadsheet for those textboxes that the user leaves empty. I have tried both of the following, but neither work.

For i = 1 To 90
Application.StatusBar = "Adding Data from Textbox" & i & " to spreadsheet."
ProgressPercent = Round(i / 90 * 100, 0)
fmProgress.pcProgress ProgressPercent
If Not IsEmpty(Controls("Textbox" & i).Value) Then
SheetToEnter.Cells(CurrentDateRow, ArrayOfColNums(i)) _
= Controls("Textbox" & i).Value
End If
Next i

and the same thing with IsNull in place of IsEmpty. I have also tried "0" and "< 0". Any ideas?

TIA
Marcotte

Doug Glancy

Textboxes
 
Marcotte,

If Controls("Textbox" & i).Value < "" Then

hth,

Doug Glancy

"Marcotte A" wrote in message
...
I have a userform with multiple (90) textboxes. The user enters data into

some of them, and then that data is transferred to the spreadsheet. (The
textboxes are not linked directly to cells). However, I do not want to
transfer the data onto the spreadsheet for those textboxes that the user
leaves empty. I have tried both of the following, but neither work.

For i = 1 To 90
Application.StatusBar = "Adding Data from Textbox" & i & " to

spreadsheet."
ProgressPercent = Round(i / 90 * 100, 0)
fmProgress.pcProgress ProgressPercent
If Not IsEmpty(Controls("Textbox" & i).Value) Then
SheetToEnter.Cells(CurrentDateRow, ArrayOfColNums(i)) _
= Controls("Textbox" & i).Value
End If
Next i

and the same thing with IsNull in place of IsEmpty. I have also tried

"0" and "< 0". Any ideas?

TIA
Marcotte




Marcotte A

Textboxes
 
tyvm - it has the added benefit of speeding the code way up too :)

"Doug Glancy" wrote:

Marcotte,

If Controls("Textbox" & i).Value < "" Then

hth,

Doug Glancy

"Marcotte A" wrote in message
...
I have a userform with multiple (90) textboxes. The user enters data into

some of them, and then that data is transferred to the spreadsheet. (The
textboxes are not linked directly to cells). However, I do not want to
transfer the data onto the spreadsheet for those textboxes that the user
leaves empty. I have tried both of the following, but neither work.

For i = 1 To 90
Application.StatusBar = "Adding Data from Textbox" & i & " to

spreadsheet."
ProgressPercent = Round(i / 90 * 100, 0)
fmProgress.pcProgress ProgressPercent
If Not IsEmpty(Controls("Textbox" & i).Value) Then
SheetToEnter.Cells(CurrentDateRow, ArrayOfColNums(i)) _
= Controls("Textbox" & i).Value
End If
Next i

and the same thing with IsNull in place of IsEmpty. I have also tried

"0" and "< 0". Any ideas?

TIA
Marcotte






All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com