dreid1011
Well-known Member
- Joined
- Jun 4, 2015
- Messages
- 3,614
- Office Version
- 365
- Platform
- Windows
Good afternoon,
I have this little snippet of code I wrote earlier today, and all was well for the intended purpose, until I added more lines above the original portion.
So, what this is supposed to do is:
Copy data from "Vet List" columns B, D & C where column Q is blank. Rows 5 to the end of data. This data is copied to "Export Active Ex" columns A, B & C respectively. Rows 2 until it's done.
This part is supposed to copy sheet "Export Active Ex" and save it as a new workbook named "Active Exemptions " & date/time & ".xlsx" with ONLY sheet "Export Active Ex" in it.
The code in red above was working as I explained and not causing any trouble. After I added the portion in blue, the new workbook that is supposed to only have sheet "Export Active Ex" in it, saves with all the sheets from the parent workbook, and then I get a extra workbook, with the single sheet as desired, named "Book #" and an error message telling me I can't save it as non-VBA while it has a "VB Project".
Can anyone see any reason why this might happen after adding the code in blue? The single sheet "Export Active Ex" has no code in it's module at all. This is making no sense to me.
Any help is much appreciated.
I have this little snippet of code I wrote earlier today, and all was well for the intended purpose, until I added more lines above the original portion.
So, what this is supposed to do is:
Copy data from "Vet List" columns B, D & C where column Q is blank. Rows 5 to the end of data. This data is copied to "Export Active Ex" columns A, B & C respectively. Rows 2 until it's done.
This part is supposed to copy sheet "Export Active Ex" and save it as a new workbook named "Active Exemptions " & date/time & ".xlsx" with ONLY sheet "Export Active Ex" in it.
Rich (BB code):
Private Sub ExportActiveList()
Dim wsAc As Worksheet, wsEx As Worksheet
Dim i As Long, nRow As Long, lRow As Long
Set wsAc = Sheets("Vet List")
Set wsEx = Sheets("Export Active Ex")
lRow = wsAc.Range("B" & Rows.Count).End(xlUp).Row
nRow = 2
Application.ScreenUpdating = False
wsEx.Range("A2:C9999").Clear
For i = 5 To lRow
If wsAc.Range("Q" & i).Value = "" Then
wsEx.Range("A" & nRow).Value = wsAc.Range("B" & i).Value
wsEx.Range("B" & nRow).Value = wsAc.Range("D" & i).Value
wsEx.Range("C" & nRow).Value = wsAc.Range("E" & i).Value
nRow = nRow + 1
End If
Next i
wsEx.Copy
wsEx.SaveAs Filename:="F:\Documents\VETERANS\ActiveExemptions " & CDbl(Now()) & ".xlsx", FileFormat:=51
Application.ScreenUpdating = True
End Sub
The code in red above was working as I explained and not causing any trouble. After I added the portion in blue, the new workbook that is supposed to only have sheet "Export Active Ex" in it, saves with all the sheets from the parent workbook, and then I get a extra workbook, with the single sheet as desired, named "Book #" and an error message telling me I can't save it as non-VBA while it has a "VB Project".
Can anyone see any reason why this might happen after adding the code in blue? The single sheet "Export Active Ex" has no code in it's module at all. This is making no sense to me.
Any help is much appreciated.