Hi,
I kindly ask for help with the following please:
The 3 Macros below can be triggered individually using 3 buttons IF you highlight a specific ROW, (for example having focus on the Cell A11) - and then click on any of the 3 individual macro buttons to execute any of the 3 macros individually. I would like to continue to use this behavior – but also combine this with a more automatic approach where:
IF cell A1 in the Sheet named (“Sheet1) contains the value 1 => Then (in the Sheet named “Orders”) automatically trigger the 1st Marco named “placeOrder” for the specific row No 11
IF cell A1 in the Sheet named (“Sheet1) contains the value 2 => Then (in the Sheet named “Orders”) automatically trigger the 2nd Marco named “cancelOrder” for the specific row No 11
IF cell A1 in the Sheet named (“Sheet1) contains the value 3 => Then (in the Sheet named “Orders”) automatically trigger the 3rd Marco named “clearOrder” for the specific row No 11
IF cell A1 in the Sheet named (“Sheet2) contains the value 1 => Then (in the Sheet named “Orders”) automatically trigger the 1st Marco named “placeOrder” for the specific row No 12
IF cell A1 in the Sheet named (“Sheet2) contains the value 2 => Then (in the Sheet named “Orders”) automatically trigger the 2nd Marco named “cancelOrder” for the specific row No 12
IF cell A1 in the Sheet named (“Sheet2) contains the value 3 => Then (in the Sheet named “Orders”) automatically trigger the 3rd Marco named “clearOrder” for the specific row No 12
Ideally I would like to update the 3 Macros individual - so that I can decide IF I would like to use the “standard” approach to execute the macros individually for the “rows” I decide to click on, OR in case for example Cell A1 in the “Sheet2”contains the Value “2” – then the macro “cancelOrder” should be triggered automatically in the Sheet “Orders”
Thanks, and the VBA code is below:
' ========================================================
' place order for active row
' ========================================================
Sub placeOrder()
Dim row As Range, server As String, lastRowIndex As Integer
server = util.getServerVal(STR_SHEET_NAME, CELL_SERVER_NAME)
If server = util.STR_EMPTY Then Exit Sub
For Each row In Selection.rows
lastRowIndex = row.row
If Not util.hasContractData(Worksheets(STR_SHEET_NAME), dataStartRowIndex, row, startOfContractColumns, getContractColumns()) Then GoTo Continue
sendPlaceOrder server, row
Continue:
Next row
Worksheets(STR_SHEET_NAME).Cells(lastRowIndex, 1).offset(0, 0).Activate
End Sub
' ========================================================
' cancel order for active row
' ========================================================
Sub cancelOrder()
Dim server As String, id As String, i As Integer, row As Range, lastRowIndex As Integer
server = util.getServerVal(STR_SHEET_NAME, CELL_SERVER_NAME)
If server = util.STR_EMPTY Then Exit Sub
With Worksheets(STR_SHEET_NAME)
For Each row In Selection.rows
lastRowIndex = row.row
If .Cells(row.row, idColumnIndex).value = STR_EMPTY Then GoTo Continue
If Not util.hasContractData(Worksheets(STR_SHEET_NAME), dataStartRowIndex, row, startOfContractColumns, getContractColumns()) Then GoTo Continue
id = .Cells(row.row, idColumnIndex).value
util.sendRequest server, STR_CANCELORDER, id
Continue:
Next row
.Cells(lastRowIndex, 1).offset(0, 0).Activate
End With
End Sub
' ========================================================
' clear order for active row
' ========================================================
Sub clearOrder()
Dim server As String, id As String, i As Integer, row As Range, lastRowIndex As Integer
server = util.getServerVal(STR_SHEET_NAME, CELL_SERVER_NAME)
If server = util.STR_EMPTY Then Exit Sub
With Worksheets(STR_SHEET_NAME)
For Each row In Selection.rows
lastRowIndex = row.row
If .Cells(row.row, idColumnIndex).value = STR_EMPTY Then GoTo Continue
If Not util.hasContractData(Worksheets(STR_SHEET_NAME), dataStartRowIndex, row, startOfContractColumns, getContractColumns()) Then GoTo Continue
id = .Cells(row.row, idColumnIndex).value
clearOrderStatusColumns row
util.sendRequest server, STR_CLEARORDER, id
Continue:
Next row
.Cells(lastRowIndex, 1).offset(0, 0).Activate
End With
End Sub
I kindly ask for help with the following please:
The 3 Macros below can be triggered individually using 3 buttons IF you highlight a specific ROW, (for example having focus on the Cell A11) - and then click on any of the 3 individual macro buttons to execute any of the 3 macros individually. I would like to continue to use this behavior – but also combine this with a more automatic approach where:
IF cell A1 in the Sheet named (“Sheet1) contains the value 1 => Then (in the Sheet named “Orders”) automatically trigger the 1st Marco named “placeOrder” for the specific row No 11
IF cell A1 in the Sheet named (“Sheet1) contains the value 2 => Then (in the Sheet named “Orders”) automatically trigger the 2nd Marco named “cancelOrder” for the specific row No 11
IF cell A1 in the Sheet named (“Sheet1) contains the value 3 => Then (in the Sheet named “Orders”) automatically trigger the 3rd Marco named “clearOrder” for the specific row No 11
IF cell A1 in the Sheet named (“Sheet2) contains the value 1 => Then (in the Sheet named “Orders”) automatically trigger the 1st Marco named “placeOrder” for the specific row No 12
IF cell A1 in the Sheet named (“Sheet2) contains the value 2 => Then (in the Sheet named “Orders”) automatically trigger the 2nd Marco named “cancelOrder” for the specific row No 12
IF cell A1 in the Sheet named (“Sheet2) contains the value 3 => Then (in the Sheet named “Orders”) automatically trigger the 3rd Marco named “clearOrder” for the specific row No 12
Ideally I would like to update the 3 Macros individual - so that I can decide IF I would like to use the “standard” approach to execute the macros individually for the “rows” I decide to click on, OR in case for example Cell A1 in the “Sheet2”contains the Value “2” – then the macro “cancelOrder” should be triggered automatically in the Sheet “Orders”
Thanks, and the VBA code is below:
' ========================================================
' place order for active row
' ========================================================
Sub placeOrder()
Dim row As Range, server As String, lastRowIndex As Integer
server = util.getServerVal(STR_SHEET_NAME, CELL_SERVER_NAME)
If server = util.STR_EMPTY Then Exit Sub
For Each row In Selection.rows
lastRowIndex = row.row
If Not util.hasContractData(Worksheets(STR_SHEET_NAME), dataStartRowIndex, row, startOfContractColumns, getContractColumns()) Then GoTo Continue
sendPlaceOrder server, row
Continue:
Next row
Worksheets(STR_SHEET_NAME).Cells(lastRowIndex, 1).offset(0, 0).Activate
End Sub
' ========================================================
' cancel order for active row
' ========================================================
Sub cancelOrder()
Dim server As String, id As String, i As Integer, row As Range, lastRowIndex As Integer
server = util.getServerVal(STR_SHEET_NAME, CELL_SERVER_NAME)
If server = util.STR_EMPTY Then Exit Sub
With Worksheets(STR_SHEET_NAME)
For Each row In Selection.rows
lastRowIndex = row.row
If .Cells(row.row, idColumnIndex).value = STR_EMPTY Then GoTo Continue
If Not util.hasContractData(Worksheets(STR_SHEET_NAME), dataStartRowIndex, row, startOfContractColumns, getContractColumns()) Then GoTo Continue
id = .Cells(row.row, idColumnIndex).value
util.sendRequest server, STR_CANCELORDER, id
Continue:
Next row
.Cells(lastRowIndex, 1).offset(0, 0).Activate
End With
End Sub
' ========================================================
' clear order for active row
' ========================================================
Sub clearOrder()
Dim server As String, id As String, i As Integer, row As Range, lastRowIndex As Integer
server = util.getServerVal(STR_SHEET_NAME, CELL_SERVER_NAME)
If server = util.STR_EMPTY Then Exit Sub
With Worksheets(STR_SHEET_NAME)
For Each row In Selection.rows
lastRowIndex = row.row
If .Cells(row.row, idColumnIndex).value = STR_EMPTY Then GoTo Continue
If Not util.hasContractData(Worksheets(STR_SHEET_NAME), dataStartRowIndex, row, startOfContractColumns, getContractColumns()) Then GoTo Continue
id = .Cells(row.row, idColumnIndex).value
clearOrderStatusColumns row
util.sendRequest server, STR_CLEARORDER, id
Continue:
Next row
.Cells(lastRowIndex, 1).offset(0, 0).Activate
End With
End Sub