Yes thanks to this amazing Forum I{m slowly getting into writing Macros but apparently not fast enough. Do need help with this one.
I have a macro that copies some cells in to protected excel database. But now I want to make the macro conditional that is
If there range named CONTROL contains data the saving macro can be executed but if these cells are blank I need an error message and go back to the named cells.
This is how far I that is despite using many example form this Forum i cant get the conditional ...............
I{m sure it is not something difficult, thanks in advance to the expert that can spare some minutes to help me out on this!
Joke
Sub Savedata()
'IF the cells in range D113:F113 (named "control") have a value
other data will be saved in separate file if not a message box will be displayed and empty cells will be selected
Dim ActiveSh As Worksheet
Dim OpenedWb As Workbook
Dim strFname As String
strFname = Range("ubicacion").value
Set ActiveSh = ActiveSheet
Set OpenedWb = Workbooks.Open(Filename:=strFname)
With OpenedWb
.ActiveSheet.Unprotect Password:="x"
.ActiveSheet.Range("A2").EntireRow.Insert
.ActiveSheet.Range("a2:M2").value = ActiveSh.Range("guardar1").value
.ActiveSheet.Protect Password:="x"
.Close True
End With
Application.Goto REference:="comienzo2"
Else
MsgBox "You have to fill the data before saving"
Style = vbOkYes
Application.Goto REference:="control"
I have a macro that copies some cells in to protected excel database. But now I want to make the macro conditional that is
If there range named CONTROL contains data the saving macro can be executed but if these cells are blank I need an error message and go back to the named cells.
This is how far I that is despite using many example form this Forum i cant get the conditional ...............
I{m sure it is not something difficult, thanks in advance to the expert that can spare some minutes to help me out on this!
Joke
Sub Savedata()
'IF the cells in range D113:F113 (named "control") have a value
other data will be saved in separate file if not a message box will be displayed and empty cells will be selected
Dim ActiveSh As Worksheet
Dim OpenedWb As Workbook
Dim strFname As String
strFname = Range("ubicacion").value
Set ActiveSh = ActiveSheet
Set OpenedWb = Workbooks.Open(Filename:=strFname)
With OpenedWb
.ActiveSheet.Unprotect Password:="x"
.ActiveSheet.Range("A2").EntireRow.Insert
.ActiveSheet.Range("a2:M2").value = ActiveSh.Range("guardar1").value
.ActiveSheet.Protect Password:="x"
.Close True
End With
Application.Goto REference:="comienzo2"
Else
MsgBox "You have to fill the data before saving"
Style = vbOkYes
Application.Goto REference:="control"