midnight76
New Member
- Joined
- Nov 15, 2020
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
Hi guys,
I'm working with these codes and I want to save as just a single worksheet but the whole workbook is saved instead.
Moreover, I wanna create a shortcut of this new Excel workbook (which containing just 1 worksheet) in another folder and It would take a pop-up that asks in which year to create the shorcut. Can someone please give it a look?
Really appreciated!!!
I'm working with these codes and I want to save as just a single worksheet but the whole workbook is saved instead.
Moreover, I wanna create a shortcut of this new Excel workbook (which containing just 1 worksheet) in another folder and It would take a pop-up that asks in which year to create the shorcut. Can someone please give it a look?
Really appreciated!!!
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
Target.Copy Worksheets("TechnicalSheet").Cells(1, 2)
Set A = ThisWorkbook.Sheets("TechnicalSheet")
Set B = Workbooks.Add
Set C = ThisWorkbook.Sheets("Rules")
A.Activate
A.Copy
With ActiveSheet.UsedRange
.Value = .Value
End With
B.Activate
B.Sheets(1).Cells.PasteSpecial Paste:=xlPasteValues
B.Sheets(1).Cells.PasteSpecial Paste:=xlPasteFormats
B.Sheets(1).Name = "NEW"
Firststep = B.Sheets("NEW").Range("H1").End(xlDown).Row
Laststep = B.Sheets("NEW").Range("H10000").End(xlUp).Row
For i = Firststep To Laststep
If B.Sheets("NEW").Cells(i, 8).Value = "Not available" Then
B.Sheets("NEW").Range("H" & i).EntireRow.Hidden = True
End If
Next i
C.Activate
C.Cells.Copy
B.Sheets(2).Cells.PasteSpecial Paste:=xlPasteValues
B.Sheets(2).Cells.PasteSpecial Paste:=xlPasteFormats
B.Sheets(2).Name = "Rules"
File = Application.GetSaveAsFilename(InitialFileName:="NEW -" & Target.Value & ".xlsm", FileFilter:= _
"Excel Files Macro Enabled" & "Workbook (*.xlsm), *xlsm")
If File = False Then
Exit Sub
End If
Application.DisplayAlerts = False
ActiveWorkSheet.SaveAs Filename:=File, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If
End Sub