Hi DairyQueen
Here's my code for placing your InputBox exactly where you want it, using the active cell as the location for the top-left-corner of the InputBox.
It works with multiple screens as well as single screens.
It even works if you 'grab' the Excel window and re-size or move the Excel window around your display..
Sub CalcWhat()
'Set zCell = [G8] '<< define anchor-cell to be used for position of InputBox
'or..
Set zCell = ActiveCell 'use current active cellpointer-cell for location
'The top-left-corner of the primary display is (0,0).
'For Excel position, negative values means left-of or above the primary screen.
'Top-left-corner position of cell [A1] in "points"; ( NOTE: 72points/inch)
'for Excel2016:
x = Application.Left + 14 '+14=fine-tune allowance for frame
y = Application.Top + CommandBars("Ribbon").Height + 2 '+2 =fine-tune-allowance for frame
'for Excel2010:
'x = Application.Left + 22 '+22=fine-tune allowance for frame
'y = Application.Top + CommandBars("Ribbon").Height - 8 '-8 =fine-tune-allowance for frame
'for Excel2007:
'x = Application.Left + 24 '+24=fine-tune allowance for frame
'y = Application.Top + CommandBars("Ribbon").Height - 3 '-3 =fine-tune-allowance for frame
a = zCell.Left 'position of left-edge of chosen cell (in points)
b = zCell.Top 'position of top-edge of chosen cell )in points)
zLeft = (x + a) / 72 'convert to inches; 72points= 1-inch); left-edge of chosen cell
zTop = (y + b) / 72 'convert to inches; 72points= 1-inch); top-edge of chosen cell
zLeft = zLeft * 1440 'now convert inches-to-twips (1440/inch)
zTop = zTop * 1440 'now convert inches-to-twips (1440/inch)
Application.Calculation = xlManual
zHeading = "Calculate What?"
saywhat = ""
saywhat = saywhat & "1 = Calculate A Used Range" & vbCr
saywhat = saywhat & "2 = Calculate This Worksheet" & vbCr
saywhat = saywhat & "3 = Calculate This Workbook" & vbCr
saywhat = saywhat & "4 = Calculate All Workbooks in Memory"
saywhat = saywhat & vbCr & vbCr
saywhat = saywhat & "Input Your Selection Number From Above" & vbCr
saywhat = saywhat & "Then Click OK" & vbCrLf
zDefault = "Input Number Please"
iAnsure = InputBox(saywhat, zHeading, zDefault, zLeft, zTop)
Select Case iAnsure
Case 1 'Range Only
Selection.Calculate
Case 2 'Worksheet Only
ActiveSheet.Calculate
Case 3 'Workbook Only
For Each wks In ActiveWorkbook.Worksheets
wks.Calculate
Next
Case 4 'All Open Workbooks
Application.CalculateFull
End
Case Else
'do nothing
End Select
End Sub
In the attached file, place your cellpointer in the cell where you want to see the InputBox, then click the button to display it (don't forget to choose a calc option or you will be left with calcs set to Manual)
I have tested this on my Excel2016. Move the cellpointer around and keep testing etc etc etc.
For my Excel2010 and Excel2007, I needed to make slight adjustments for fine-tuning the exact cellpointer location .
I left these adjustments in the code, for the benefit of others using those Excel versions.
Note that you cannot use this with Excel2003 (it doesn't have a "Ribbon").
Also, this assumes that you aren't messing around with zoom-display settings, and you are displaying the Excel frame for row-column etc etc etc.
zeddy
Bookmarks