Mirror Negative w/ Alpha - help with this

jonfull

New Member
Joined
Aug 31, 2010
Messages
5
I have data coming in that looks like:
<table border="0" cellpadding="0" cellspacing="0" width="147"><colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:694;width:14pt" width="19"> <col style="width:48pt" width="64"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:48pt" height="20" width="64">Desire:</td> <td style="width:14pt" width="19">
</td> <td style="width:48pt" width="64">TEXT:</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0008201</td> <td class="xl65">
</td> <td class="xl65">820a</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0001112</td> <td class="xl65">
</td> <td class="xl65">111b</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0001223</td> <td class="xl65">
</td> <td class="xl65">122c</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0001334</td> <td class="xl65">
</td> <td class="xl65">133d</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0001445</td> <td class="xl65">
</td> <td class="xl65">144e</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0000056</td> <td class="xl65">
</td> <td class="xl65">5f</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0949867</td> <td class="xl65">
</td> <td class="xl65">94986g</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">0949878</td> <td class="xl65">
</td> <td class="xl65">94987h</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl66" style="height:15.0pt" height="20" align="right">-100011</td> <td class="xl66">
</td> <td class="xl65">10001j</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl66" style="height:15.0pt" height="20" align="right">-010002</td> <td class="xl66">
</td> <td class="xl65">1000k</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl66" style="height:15.0pt" height="20" align="right">-000003</td> <td class="xl66">
</td> <td class="xl65">0l</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl66" style="height:15.0pt" height="20" align="right">-000110</td> <td class="xl66">
</td> <td class="xl65">11}</td> </tr> </tbody></table>

Where:
{=0
a=1
b=2
c=3
d=4
}=-
j=-1
k=-2
l=-3
m=-4

I've got the vba figured out for the positive translations, but i cannot figure out how to change the cell to negative. (Again, I need help making it negative and replacing the character at the end. I can only figure out how to replace the character and replace the font to red...)

this is what I have so far:
For Each c In Range("a2", Range("a" & Rows.Count).End(xlUp))
H = c
For a = 1 To Len(H)
If Not IsNumeric(Mid(H, a, 1)) Then
Select Case Mid(LCase(H), a, 1)
Case "a"
Mid(H, a, 1) = "1"
Case "b"
Mid(H, a, 1) = "2"
Case "c"
Mid(H, a, 1) = "3"
Case "d"
Mid(H, a, 1) = "4"
Case "e"
Mid(H, a, 1) = "5"
Case "f"
Mid(H, a, 1) = "6"
Case "g"
Mid(H, a, 1) = "7"
Case "h"
Mid(H, a, 1) = "8"
Case "i"
Mid(H, a, 1) = "9"
Case "{"
Mid(H, a, 1) = "0"


Case "}"
'NONE OF THESE WORK:
' c.Value = "'-'" & c.Value
'c.Font.ColorIndex = 3
' c.Value.InsertAfter Chr(1), "abc"
'c.Value = Left(c, 2) = "-1" & Mid(H, a, 1) = "0"
' c.Formula = ActiveCell.Value * -1
' c.Value = Evaluate(c.Address & "*-1")
'value ("-1)").Operation:=xlMultiply("-1")
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I set up a 'lookup table' that looked like this; I guessed a few of them but I think I got them right. I then assigned it the name LU

Excel Workbook
GHI
1CodeDigitSign
2{01
3a11
4b21
5c31
6d41
7e51
8f61
9g71
10h81
11i91
12}0-1
13j1-1
14k2-1
15l3-1
16m4-1
17n5-1
18o6-1
19p7-1
20q8-1
21r9-1
Sheet1
#VALUE!
Excel 2007
Cell Formulas
RangeFormula
B2=(LEFT(A2, LEN(A2)-1)&VLOOKUP(RIGHT(A2, 1), LU, 2, FALSE))*VLOOKUP(RIGHT(A2, 1), LU, 3, FALSE)
Excel Workbook
NameRefers To
LU=Sheet1!$F$1:$H$21
Workbook Defined Names



I hope this might help.

Regards
Adam
 
Upvote 0
I'm looking for a vba script, because I'm also having it automate several other functions that are necessary. This will also be a template of sorts, so that people won't have to go in and do any kind of formula's on their own, etc...hoping to reduce errors and standardize with this...
 
Upvote 0
OK. I'm sorry I don't have enough time to look through all your code but my brief thoughts are that you might be able to adapt some of my code. It looks like your looping is a little excessive. Then you'd just need to Select Case based on the final character. Convert it to a value using Val() and then just multiply by -1 to get a negative number.

If this is still unanswered tomorrow morning I'll take another look.

Regards
Adam
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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