cell with wrap text and merge and center

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
266
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
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
2,920
.
Don't use merged cells. They cause more issues than is worth the visual appearance.
 

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
266
in my situation i use it a lot if you can possibility help with a vba code i would appreciate it

Thanks
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,504
Office Version
2010
Platform
Windows
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]
 

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
266
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
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,504
Office Version
2010
Platform
Windows
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
 

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
266
HI

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

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
266
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
 

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
266
I Tried application.worksheetfunction.mround
but i'm getting an error
 

Forum statistics

Threads
1,081,969
Messages
5,362,477
Members
400,676
Latest member
BiochemBoi95

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top