I love playing Mafia Wars on Facebook.
One of the thing you do in the game is collect items and use these
items to do specific things like fighting.
This is my attempt at creating a spreadsheet that will list all my
Weapons, Armour & Vehicles.
After going selecting a random person to fight, I clicked on "( show
all items used )". I selected all the text of the Items I was using.
Next I Copy then paste into the Form on the "get" sheet of the
spreadsheet. You can see that there are Buttons that will process
either Weapons, Armour or Vehicles.
Even if you don't know about the game, basically I'm trying to take a
chunk of text and process it into separate sheets.
Doesn't always work, and I'm still tinkering with it. Try it out and
tell me what you think. Please let me know if you might see something
that will help.
http://littleredhairedgirl.me/mafia/items.xls
Here is the text I'm Processing
Weapons
a Siberian Tiger, a Dragunov, 4 Para 322s, 9 BA-12 Assault Rifles, 2
Ma Barker's Machine Guns, 28 M16A1s, 25 RA-92s, 2 VSK-94 Sniper
Rifles, 3 Tora Assault Rifles, 20 Blunderbusses, 4 IZH-35ms, 32
Napalms, 4 Machine Gun Kelly's Guns, 26 Garza 9s, 2 Sodium Pentothals,
26 Carnivore Urban Shotguns, 8 Bookie's Holdout Pistols, 2 PPSH 41
Submachine guns, 4 Pretty Boy Floyd's .45s, a Baby Face Nelson's .351,
36 Spares, 105 Bonus weapons, 2 Graches, 16 Ru-38 Pistols, 33 RPG
Launchers, 8 Gaff hooks, 3 Claymores, 25 CA-10 TMPs, 7 Cane Knives
Armor
45 Street Gang Members, 3 Wise Guys, 32 Camouflage Body Armors, 8
Hired Thugs, 2 Tracksuits, 3 Camo Fatigues, 3 Tigerskin Armored Vests,
4 Ushankas, 3 Jungle Trackers, 31 Lefty Guns' Leather Coats, 8 Local
Toughs, 41 Bodyguards, 2 Local Guides, 40 Night Vision Goggles, 214
Body Armors
Vehicles
2 Tigershark Submersibles, a Bonnie & Clyde's B-400, 10 Montaine 320s,
a Le Tigre, 6 Multi-Purpose Trucks, 2 Cigarette Boats, 25 Chucho FAVs,
15 Mara Serpientes, 12 GX9s, 19 Choppers, a Taksi, 6 Ocelot Armored
Trucks, 2 4x4s, 2 Mototsykls, 3 CM Vengas, a Capone's Armored 341A, 24
Armored Cars, 2 Barges, 2 CM Setas, 18 Luxury Yachts, 226 Town Cars,
12 Getaway Cruisers, 26 Prop planes, 20 Armored Sedans, an Armored
Truck
Have is the code that I'm having trouble with....
(put the text above into you clipboard)
Sub DoJob()
'
' Macro11 Macro
'
'
Application.Run "Book2_clean.xls!GetClipboard"
Application.Run "Book2_clean.xls!AddWeaponsSheet"
Application.Run "Book2_clean.xls!GetWeapons"
Application.Run "Book2_clean.xls!SplitWeapons"
Application.Run "Book2_clean.xls!TallyWeapons"
Application.Run "Book2_clean.xls!ReturnToArmour"
End Sub
Sub GetClipboard()
Range("A1").Select
ActiveSheet.PasteSpecial Format:="Text", Link:=False,
DisplayAsIcon:= _
False
Range("A1").Select
End Sub
Sub AddWeaponsSheet()
Dim ActNm As String
With ActiveWorkbook.Sheets
..Add after:=Worksheets(Worksheets.Count)
End With
ActNm = ActiveSheet.Name
ActiveSheet.Name = "Weapons"
End Sub
Sub GetWeapons()
Dim T As String, S As Variant
ActiveCell.Offset(1, 0).Range("A1").Select
With Worksheets("Sheet1")
T = ActiveCell.Value
End With
S = Split(T, ",")
With Worksheets("Weapons")
.Range("A1").Resize(UBound(S) + 1) = Application.Transpose(S)
End With
End Sub
Sub SplitWeapons()
Sheets("Weapons").Select
Dim myRange As Range, lngLastRow As Long
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set myRange = Range("B1:B" & lngLastRow)
myRange.Formula = "=IF(ISNUMBER(VALUE(LEFT((A1),FIND(char(32)," & _
"TRIM(A1))))),VALUE(LEFT((A1),FIND(char(32),TRIM(A1)))),1)"
Set myRange = Range("C1:C" & lngLastRow)
myRange.Formula = "=TRIM(MID(TRIM(A1),FIND(char(32),TRIM(A1)),LEN
(A1)))"
End Sub
Sub TallyWeapons()
Sheets("Weapons").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove
Range("C1").Select
ActiveCell.FormulaR1C1 = "=SUM(C[-1])"
Range("D1").Select
End Sub
Sub ReturnToArmour()
Sheets("Sheet1").Select
Range("A5").Select
End Sub
Sub AddArmourSheet()
Dim ActNm As String
With ActiveWorkbook.Sheets
..Add after:=Worksheets(Worksheets.Count)
End With
ActNm = ActiveSheet.Name
ActiveSheet.Name = "Armour"
End Sub
Sub GetArmour()
Dim T As String, S As Variant
ActiveCell.Offset(1, 0).Range("A1").Select
With Worksheets("Sheet1")
T = ActiveCell.Value
End With
S = Split(T, ",")
With Worksheets("Armour")
.Range("A1").Resize(UBound(S) + 1) = Application.Transpose(S)
End With
End Sub
Sub SplitArmour()
Sheets("Armour").Select
Dim myRange As Range, lngLastRow As Long
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set myRange = Range("B1:B" & lngLastRow)
myRange.Formula = "=IF(ISNUMBER(VALUE(LEFT((A1),FIND(char(32)," & _
"TRIM(A1))))),VALUE(LEFT((A1),FIND(char(32),TRIM(A1)))),1)"
Set myRange = Range("C1:C" & lngLastRow)
myRange.Formula = "=TRIM(MID(TRIM(A1),FIND(char(32),TRIM(A1)),LEN
(A1)))"
End Sub
Sub TallyArmour()
Sheets("Armour").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAbove
Range("C1").Select
ActiveCell.FormulaR1C1 = "=SUM(C[-1])"
Range("D1").Select
End Sub