cell with wrap text and merge and center

BORUCH

Well-known Member
Joined
Mar 1, 2016
Messages
548
Office Version
  1. 365
Platform
  1. Windows
Question

if i have cell A1 and cell A2 merged together with wrapped text, and i want to increase each individual number by a certain percent how would i get that done for ex.

$100.25 ZZ
$200.25 ZA

through excel VBA
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
.
Don't use merged cells. They cause more issues than is worth the visual appearance.
 
Upvote 0
in my situation i use it a lot if you can possibility help with a vba code i would appreciate it

Thanks
 
Upvote 0
Select the merged cell and then run this macro...
Code:
[table="width: 500"]
[tr]
	[td]Sub IncreaseWrappedTextByCertainPercent()
  Dim X As Long, IncreaseBy As Double, Parts() As String
  IncreaseBy = 0.15  ' 15 percent
  Parts = Split(ActiveCell.Value, vbLf)
  For X = 0 To UBound(Parts)
    Parts(X) = Format((1 + IncreaseBy) * Val(Replace(Parts(X), "$", "")), "$0.00") & Mid(Parts(X), InStr(Parts(X), " "))
  Next
  Selection = Join(Parts, vbLf)
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
hi

Thanks so much that worked perfectly !

One more question how would i identify a cell that has wrapped text and merge center for ex.

what if statement in VBA can i use to say ,that it should only run your code if the cell has this type of formatting
 
Upvote 0
One more question how would i identify a cell that has wrapped text and merge center for ex.

what if statement in VBA can i use to say ,that it should only run your code if the cell has this type of formatting
I'll use Selection for the cell reference, but you can replace it with any valid cell range reference...

If Selection.MergeCells And Selection.WrapText Then
 
Upvote 0
HI

I would also need to identify if the cell has multiple lines like my first example.
 
Upvote 0
hi

if i wanted to round the number to the nearest nickel just to make it look nicer ,like the mround function how would i fit it in this code
 
Upvote 0
I Tried application.worksheetfunction.mround
but i'm getting an error
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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