Transcribe the result of an InputBox into a cell.
Solved
volfoss
Posted messages
43
Status
Member
-
volfoss Posted messages 43 Status Member -
volfoss Posted messages 43 Status Member -
Bonjour,
I created a macro but I would like to perform the following action. The response entered (which will only be a year in the format YYYY) in the InputBox must be written in cells B2:F2.
Additionally, how can I ensure that if we click cancel or on the cross, the InputBox closes without receiving the type mismatch error and runtime error 13?
Thank you for your help.
Sub CreateRings()
Dim Rep As Integer
If Rep = InputBox("Remember to enter the breeding season in B2", "Breeding season") Then 'The variable receives the value entered in the InputBox
If Rep = vbOK Then
' here the processing if positive response
ActiveCell.FormulaR1C1 = "" 'display the InputBox response
Selection.Copy
Range("B2:F2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Else
' here the processing if negative response
End If
End Sub
I created a macro but I would like to perform the following action. The response entered (which will only be a year in the format YYYY) in the InputBox must be written in cells B2:F2.
Additionally, how can I ensure that if we click cancel or on the cross, the InputBox closes without receiving the type mismatch error and runtime error 13?
Thank you for your help.
Sub CreateRings()
Dim Rep As Integer
If Rep = InputBox("Remember to enter the breeding season in B2", "Breeding season") Then 'The variable receives the value entered in the InputBox
If Rep = vbOK Then
' here the processing if positive response
ActiveCell.FormulaR1C1 = "" 'display the InputBox response
Selection.Copy
Range("B2:F2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Else
' here the processing if negative response
End If
End Sub