Help on coding please

E

Eric

Under Temp worksheet, there is 0.03 (2.6%) in cell A1.
I would like to copy anything inside the blanket (), in this case, I would
like to copy 2.6% into cell B1 under Summary worksheet.
Does anyone have any suggestions on how to do it in macro coding?
Thanks in advance for any suggestions
Eric
 
D

Don Guillett

Don't really understand what you want but this will copy the cell

sheets("temp").range("a1").copy sheets("summary").range("b1")
 
R

Rick Rothstein \(MVP - VB\)

Like Don, I am unsure what you actually want. I think you are saying you
have the text "0.03 (2.6%)" in Temp!A1 and you want to put the "2.6%" part
into Summary!B1. If so, you don't need to use a macro to do that; you can
use this formula in Summary!B1 instead...

=MID(Temp!A1,FIND("(",Temp!A1)+1,LEN(Temp!A1)-FIND("(",Temp!A1)-1)

If the contents of Temp!A1 do not have both an opening and closing
parenthesis, you will get a #VALUE! in Summary!B1.

Rick
 
E

Eric

I would like to trim the string,
for example
The string is 0.03 (2.6%), in order to retrieve value within blanket
then trim this string and get the value 2.6%, that is what I want.

Get 2.6% from 0.03 (2.6%)

Do you have any suggestions?
Thank you very much for any suggestions
Eric
 
R

Rick Rothstein \(MVP - VB\)

If you can't use the direct formula I posted in my other response, you can
use this macro code to do what you asked...

Sub GetPercentage()
Dim CellText As String
CellText = Worksheets("Temp").Range("A1").Value
Worksheets("Summary").Range("B1").Value = Mid(CellText, InStr(CellText, _
"(") + 1, Len(CellText) - InStr(CellText, "(") - 1)
End Sub

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top