View Single Post
 
Old 12-14-2014, 11:14 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Frankly that won't be the only problem. While trying to decipher your code, it was apparent that you had not defined 'oRng', or 'Source' and you referred to the Userform in the userform code as e.g

Code:
UserForm1.TextBox1.Value = pStr1
rather than
Code:
Me.TextBox1.Value = pStr1
It also helps to give the userform and its elements unique names.

I am also not sure what

Code:
Me.Hide
UserForm1.Show
is trying to achieve.

The various values you have assigned to pStr1 etc are already in the list and combo boxes (assuming that part of the code works) in the hidden columns, so adding those values to the text boxes seems unnecessary? You can call them to the document directly from the list and combo boxes and make the form much simpler.

As for your original question, test whether the column has data before trying to use it and if it doesn't have a value, give it one.

Take the line

Code:
 pStr1 = .Column(0, Me.ComboBox1.ListIndex)
You could use e.g.

Code:
If Not .Column(0) = "" then
    pstr1 = .column(0)
Else
    pstr1 = " "
End if
Without the missing information the rest is guesswork.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote