ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Quick Macro help (https://www.excelbanter.com/excel-discussion-misc-queries/178187-quick-macro-help.html)

KJ

Quick Macro help
 
Below is a macro I want to run when I open a workbook. I need to make a
change though however and I don't know how to language the code.
I only want to run the macro below if there is a value in cell F8. If F8 is
blank, then I want to end the macro, or just do nothing.
Thanks for any help.



Private Sub Workbook_Open()
'
' QuoteNumber Macro
'

'
Range("F8").Select
Selection.Copy
Range("D8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F8").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("B5").Select

End Sub


Jim Thomlinson

Quick Macro help
 
Give this a try...

Private Sub Workbook_Open()
'
' QuoteNumber Macro
'

'you really should select a sheet
if Range("F8").value < ""
Range("D8").value = Range("F8").value
Range("F8").value = ""
Range("B5").Select
End if
End Sub

--
HTH...

Jim Thomlinson


"KJ" wrote:

Below is a macro I want to run when I open a workbook. I need to make a
change though however and I don't know how to language the code.
I only want to run the macro below if there is a value in cell F8. If F8 is
blank, then I want to end the macro, or just do nothing.
Thanks for any help.



Private Sub Workbook_Open()
'
' QuoteNumber Macro
'

'
Range("F8").Select
Selection.Copy
Range("D8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F8").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("B5").Select

End Sub



All times are GMT +1. The time now is 04:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com