Populating a dialogbox

P

Patrick Simonds

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
 
R

Rowan

Maybe like this:

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

Regards
Rowan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Create a public variable 4
Stumped 1
store variables 4
Run code from within a UserForm 2
TextBoxes and Data Filtering 7
UserForm Intialization 3
Referencing a UserForm 2
Hide a TextBox 1

Top