ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,737
- Office Version
- 2007
- Platform
- Windows
Hi,
Can you please advise the way to merge the following codes.
Then i will have the 1 button the press to run both codes.
Many Thanks for all your help.
Then code below added after the above code,
Can you please advise the way to merge the following codes.
Then i will have the 1 button the press to run both codes.
Many Thanks for all your help.
Code:
Sub LEADERBOARD() '' leaderboard Macro' Range("C1:F17").Copy Range("I1")
Worksheets("HONDA SHEET").Range("C1:D17").Copy Worksheets("SOLD ITEMS").Range("C2:D19")
Worksheets("HONDA SHEET").Range("E1:F17").Copy Worksheets("SOLD ITEMS").Range("C19:D35")
ActiveWorkbook.Worksheets("SOLD ITEMS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("SOLD ITEMS").Sort.SortFields.Add Key:=Range("D2"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortTextAsNumbers
With Worksheets("SOLD ITEMS").Sort
.SetRange Range("C2:D35")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
With Worksheets("SOLD ITEMS").Range("C2:D35").Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
End With
Application.Goto Sheets("SOLD ITEMS").Range("A5")
End Sub
Then code below added after the above code,
Code:
Private Sub CommandButton1_Click()Dim myStr As String
Dim x As Integer
Dim myRange As Range
Set myRange = Sheets("SOLD ITEMS").Range("C2:D35")
myData = myRange.Value
For x = 1 To UBound(myData, 1)
myStr = myStr & myData(x, 1) & vbTab & myData(x, 2) & vbCrLf
Next x
MsgBox myStr
End Sub