Dear Experts,
Unfortunately I'm not good at vba coding and I cannot figure out why the last Call in the following code does not work and gives a "Runtime error '9' - Subscript out of range" error.
The macro to be called runs perfectly when started manually.
Here is the main code:
And this is the NyersStockSort macro on Sheet19:
Any help would be highly appreciated.
All the best,
Balazs
Unfortunately I'm not good at vba coding and I cannot figure out why the last Call in the following code does not work and gives a "Runtime error '9' - Subscript out of range" error.
The macro to be called runs perfectly when started manually.
Here is the main code:
Code:
Sub CommandButton1_Click()
Worksheets("NyersanyagRaktár").Range("G6:G100").Value = Worksheets("NyersanyagBeszerzés").Range("C6:C100").Value
Worksheets("NyersanyagRaktár").Range("B6:B100").Value = Worksheets("NyersanyagRaktár").Range("E6:E100").Value
Worksheets("NyersanyagRaktár").Range("C6:C100").Value = Worksheets("NyersanyagRaktár").Range("I6:I100").Value
Worksheets("BeszerzésTemp").Range("A6:J100").Value = Worksheets("NyersanyagBeszerzés").Range("A6:J100").Value
Range("C6:E100").Select
Selection.ClearContents
Range("H6:I100").Select
Selection.ClearContents
Worksheets("Nyersanyagraktár").Activate
Worksheets("Nyersanyagraktár").Range("G6.G100").Select
Selection.ClearContents
Call Sheet17.Purchasedelrowsifzero
Application.CopyObjectsWithCells = False
ActiveWorkbook.Sheets("BeszerzésTemp").Copy
Call Sheet17.SaveUnique
Call Sheet17.CopyStuff
Call Sheet19.NyersStockSort
End Sub
And this is the NyersStockSort macro on Sheet19:
Code:
Public Sub NyersStockSort()
ActiveWorkbook.Worksheets("NyersanyagRaktarTeteles").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("NyersanyagRaktarTeteles").Sort.SortFields.Add Key _
:=Range("B6:B300"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("NyersanyagRaktarTeteles").Sort.SortFields.Add Key _
:=Range("J6:J300"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("NyersanyagRaktarTeteles").Sort
.SetRange Range("B6:J300")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Any help would be highly appreciated.
All the best,
Balazs
Last edited by a moderator: