Excel VBA HOW TO PRINT THE TEXT IN A CELL like Wrap Text

0 votes

When the code is executed, the text "AASD FDG HJK LSDH YTWIN" appears in a cell, however, I need the words to appear in a cell enclosed like:

AASD
FDG
HJK
LSDH
YTWIN

This is one cell. what changes needs to be done to get like that for this code:

Ws.Range("E" & R).Value = "AASD FDG HJK LSDH YTWIN " 
Oct 27, 2022 in Others by Kithuzzz
• 28,900 points
193 views

1 answer to this question.

0 votes

Use a LineFeed character to create a line break in an Excel cell. In VBA, a constant vbLf is defined for that. Additionally, the cell's WrapText attribute must be set.

So you can use:

With ws.Range("E" & R) 
    .WrapText = True
    .Value = "AASD" & vbLf & "FDG" & vbLf & "HJK" & vbLF & "LSDH" & vbLF & "YTWIN"
    ' Or use
    .Value = Replace("AASD FDG HJK LSDH YTWIN ", " ", vbLf) 
end With
answered Oct 27, 2022 by narikkadan
• 53,520 points

Related Questions In Others

0 votes
1 answer

How do I use the Indirect Function in Excel VBA to incorporate the equations in a VBA Macro Function

Try this: Sub Test() Dim str As String: str ...READ MORE

answered Jan 19 in Others by narikkadan
• 53,520 points
62 views
0 votes
1 answer

Create a hyperlink to a sheet with same name as the value in the selected cell in Excel through VBA

Credit to Spectral Instance who found the ...READ MORE

answered 2 days ago in Others by narikkadan
• 53,520 points
26 views
0 votes
1 answer

How to retrieve the value of a text field in Flutter App?

Hi@akhtar, In your TextField, you can call one ...READ MORE

answered Sep 3, 2020 in Others by MD
• 95,420 points
1,115 views
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 53,520 points
240 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
532 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,414 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 22,960 points
117 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,630 points
299 views
0 votes
1 answer

Excel-VBA - How to identify Target range (more than 1 cell) is deleted in a Worksheet_Change function?

You misunderstand the purpose of the function ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 53,520 points
1,180 views
0 votes
1 answer

How to insert a new row in the specified cell only, of Excel sheet using c#?

I have this worksheet with a matrix ...READ MORE

answered Nov 24, 2022 in Others by narikkadan
• 53,520 points
277 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP