Hi,
I attempted to attach the following Macro to a button. I have already run successfully from VBA editor so didn't abticiapate any problems, but when I tried to run it the following:
Run Time error 1004 Select Method of Range Class Failed.
And it stoppe don teh line:
Range("A1").Select
but it workrs when I go into it in VBE and press run??
Sub Consolidate()
Dim x As Single
Dim y As Double
Dim n As Integer
n = 2
Dim Rows As Single
Worksheets("SWAPS Data").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
'ActiveWindow.SmallScroll Down:=-1
Rows = Selection.Cells.Count
For x = 2 To Rows
If Cells(x, 19).Value <> "" Then
If Cells(x, 19).Value <> 0 Then
trade = Cells(x, 1)
float = Cells(x, 19)
Dates = Cells(x, 21)
Worksheets("Process").Cells(n, 3).Value = float
Worksheets("Process").Cells(n, 1).Value = Dates
Worksheets("Process").Cells(n, 2).Value = trade
Worksheets("Process").Cells(n, 4).Value = "jpy"
n = n + 1
End If
End If
Next x
'For x = 2 To Rows
'If Cells(x, 20).Value <> "" Then
'If Cells(x, 20).Value <> 0 Then
'trade = Cells(x, 1)
'float = Cells(x, 20)
'Dates = Cells(x, 21)
'Worksheets("Process").Cells(n, 3).Value = float
'Worksheets("Process").Cells(n, 1).Value = Dates
'Worksheets("Process").Cells(n, 2).Value = trade
'Worksheets("Process").Cells(n, 4).Value = "jpy"
'n = n + 1
'End If
'End If
'Next x
For x = 2 To Rows
If Cells(x, 23).Value <> "" Then
If Cells(x, 23).Value <> 0 Then
trade = Cells(x, 1)
float = Cells(x, 23)
Dates = Cells(x, 24)
Worksheets("Process").Cells(n, 3).Value = float
Worksheets("Process").Cells(n, 1).Value = Dates
Worksheets("Process").Cells(n, 2).Value = trade
Worksheets("Process").Cells(n, 4).Value = "jpy"
n = n + 1
End If
End If
Next x
For x = 2 To Rows
If Cells(x, 28).Value <> "" Then
If Cells(x, 28).Value <> 0 Then
trade = Cells(x, 1)
float = Cells(x, 28)
Dates = Cells(x, 30)
Worksheets("Process").Cells(n, 3).Value = float
Worksheets("Process").Cells(n, 1).Value = Dates
Worksheets("Process").Cells(n, 2).Value = trade
Worksheets("Process").Cells(n, 4).Value = "usd"
n = n + 1
End If
End If
Next x
For x = 2 To Rows
If Cells(x, 32).Value <> "" Then
If Cells(x, 32).Value <> 0 Then
trade = Cells(x, 1)
float = Cells(x, 32)
Dates = Cells(x, 33)
Worksheets("Process").Cells(n, 3).Value = float
Worksheets("Process").Cells(n, 1).Value = Dates
Worksheets("Process").Cells(n, 2).Value = trade
Worksheets("Process").Cells(n, 4).Value = "usd"
n = n + 1
End If
End If
Next x
Worksheets("FX Data").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Rows = Selection.Cells.Count
For x = 2 To Rows
If Cells(x, 16).Value <> "" Then
If Cells(x, 16).Value <> 0 Then
trade = Cells(x, 1)
'USD = Cells(x, 15)
JPY = Cells(x, 16)
Dates = Cells(x, 17)
'Worksheets("Process").Cells(n, 3).Value = USD
'Worksheets("Process").Cells(n, 4).Value = "USD"
Worksheets("Process").Cells(n, 3).Value = JPY
Worksheets("Process").Cells(n, 4).Value = "jpy"
Worksheets("Process").Cells(n, 1).Value = Dates
Worksheets("Process").Cells(n, 2).Value = trade
n = n + 1
End If
End If
Next x
For x = 2 To Rows
If Cells(x, 15).Value <> "" Then
If Cells(x, 15).Value <> 0 Then
trade = Cells(x, 1)
USD = Cells(x, 15)
'JPY = Cells(x, 16)
Dates = Cells(x, 17)
Worksheets("Process").Cells(n, 3).Value = USD
Worksheets("Process").Cells(n, 4).Value = "usd"
'Worksheets("Process").Cells(n, 3).Value = JPY
'Worksheets("Process").Cells(n, 4).Value = "JPY"
Worksheets("Process").Cells(n, 1).Value = Dates
Worksheets("Process").Cells(n, 2).Value = trade
n = n + 1
End If
End If
Next x
'Rows = ActiveSheet.UsedRange.Rows.Count
'For x = q
End Sub
:mad::mad: