ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating a dialogbox (https://www.excelbanter.com/excel-programming/341064-populating-dialogbox.html)

Patrick Simonds

Populating a dialogbox
 
I am using the code below to populate a dialogbox. I only want this to work
if there is a value in the selected cell. If there is a formula and not a
value then I want the Textboxes to be empty.


Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Text = rng(1, 1).Value
TextBox2.Text = rng(1, 2).Value
TextBox3.Text = rng(1, 3).Value
TextBox4.Text = rng(1, 4).Value
End Sub



Rowan[_9_]

Populating a dialogbox
 
Maybe like this:

If Not rng(1, 1).HasFormula Then
TextBox1.Text = rng(1, 1).Value
End If

Regards
Rowan

Patrick Simonds wrote:
I am using the code below to populate a dialogbox. I only want this to work
if there is a value in the selected cell. If there is a formula and not a
value then I want the Textboxes to be empty.


Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Text = rng(1, 1).Value
TextBox2.Text = rng(1, 2).Value
TextBox3.Text = rng(1, 3).Value
TextBox4.Text = rng(1, 4).Value
End Sub



Patrick Simonds

Populating a dialogbox
 
Thanks, that did the trick


"Rowan" wrote in message
...
Maybe like this:

If Not rng(1, 1).HasFormula Then
TextBox1.Text = rng(1, 1).Value
End If

Regards
Rowan

Patrick Simonds wrote:
I am using the code below to populate a dialogbox. I only want this to
work if there is a value in the selected cell. If there is a formula and
not a value then I want the Textboxes to be empty.


Private Sub UserForm_Initialize()
Dim rng
Set rng = Cells(ActiveCell.Row, 1)

TextBox1.Text = rng(1, 1).Value
TextBox2.Text = rng(1, 2).Value
TextBox3.Text = rng(1, 3).Value
TextBox4.Text = rng(1, 4).Value
End Sub




Rowan[_9_]

Populating a dialogbox
 
You're welcome.

Patrick Simonds wrote:
Thanks, that did the trick



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

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