Using VBA how can I set the limit to carriage return and start a new line when the string exceeds the page setup?

Cmack

New Member
Joined
May 23, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
I am using this code to pull data from sheet3("G5"), when it inserts it goes beyond the page limits, any ideas on how to auto include starting a new line for the data?
If InStr(TextBox2.Value, " 5 ") Then
Dim lastRow As Long
lastRow = wsGroup.Cells(wsGroup.Rows.Count, "K").End(xlUp).Row + 1
wsGroup.Range("K" & lastRow + 1).Value = wsSheet3.Range("G5").Value
end if
I would upload a screen shot, but this seems beyond my current capabilities on this site :(
Any help or feedback appreciated,
Cheers,
Cmack
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
To be able to guess where the error occurred, we need to see all the code and know which module it is in.
As for the insertion of a picture:
image.png
 
Upvote 0
1687334443167.png

as you can see the data from ("G5") spills over onto Q and R, no error is thrown, I just want a carriage return to be enforced onto a new line when the limit on "P" is reached
The same code is reused for 6, then 7 then 8 if the values are in textbox2. Thanks for your response though!! -and thanks for showing me how to post a pic LOL!!
Cheers,
Cmack
 
Upvote 0

Forum statistics

Threads
1,215,701
Messages
6,126,297
Members
449,308
Latest member
VerifiedBleachersAttendee

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