User Form Problem

kgkev

Well-known Member
Joined
Jun 24, 2008
Messages
1,291
Office Version
  1. 365
Platform
  1. Windows
I run a code that extracts some text from a database.

I have two problems.
1. the line break character displays as a Carriage Return symbol rather than a line break.
2. [SOLVED]<solved<solved>The actual information displayed is always one step behind.
By this I mean, I run it for part A it displays nothing.
Then run for part B it shows part A
then run is for part C it shows part B
then run is for part A it shows part C</solved<solved>


Code:
Sub get_tech()
Dim prod As Variant
Dim tech_desc As String
If Intersect(ActiveCell, Range("A4:AN5600")) Is Nothing Then
    MsgBox "Please select a product line", vbInformation
    Exit Sub
End If
Set prod = Cells(ActiveCell.Row, "A")
Sheets("Tech").Range("A1").Value = prod
Sheets("tech").Calculate
tech_desc = Sheets("Tech").Range("A1").Value


If Sheets("Tech").Range("N3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("N3").Value
End If
If Sheets("Tech").Range("B3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("B3").Value
End If
If Sheets("Tech").Range("C3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("C3").Value
End If
If Sheets("Tech").Range("D3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("D3").Value
End If
If Sheets("Tech").Range("E3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("E3").Value
End If
If Sheets("Tech").Range("F3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("F3").Value
End If
If Sheets("Tech").Range("G3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("G3").Value
End If
If Sheets("Tech").Range("H3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("H3").Value
End If
If Sheets("Tech").Range("I3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("I3").Value
End If
If Sheets("Tech").Range("J3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("J3").Value
End If
If Sheets("Tech").Range("K3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("K3").Value
End If
If Sheets("Tech").Range("L3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("L3").Value
End If
If Sheets("Tech").Range("M3").Value <> "" Then
    tech_desc = tech_desc & vbNewLine & Sheets("Tech").Range("M3").Value
End If


UF1.Show False
UF1.TB1.Value = tech_desc
UF1.Repaint


End Sub


any suggestions welcome
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Problem 2 resolved, I added a manual query refresh rather than allowing the data to refresh on cell change :)

Still struggling with the & vbNewLine & displaying a character rather than a new line
 
Upvote 0
Is your textbox set as multiline=true
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top