AnthonyMinnaar

New Member
Joined
Aug 25, 2020
Messages
17
Office Version
  1. 2013
Platform
  1. Windows
Hi folks!

i'm making a post for CNC machine (fanuc control). but the problem is, that when I export to a .TAP file, the machine reads the blank rows, and inserts a ";". which isn't that much of a disaster, but I'd like to make the posted programs as clean and clear as possible.

I'm currently using this code

Sub POST()
Sheets("PROGRAMMA").Select

Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False

For Each c In Range("A2:A70")
If c.Value = "" Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next

Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
xTitleId = "SELECTIE"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("SELECTIE", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="TAP (*.TAP), *.TAP")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

What should I change in here, so that it always uses a static range (e.g. A1 to G70), and not having to constantly select what range is to be exported. also, this code also still exports the hidden rows, is there a workaround so it only exports the visible rows within the static range?

as you probably can tell, I'm quite a rookie when it comes to VBA, so my apologies if this thread is unclear.


with kindest regards,

Anthony
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,096
Office Version
  1. 2016
Platform
  1. Windows
Replace: WorkRng.Copy
with
VBA Code:
WorkRng.SpecialCells(xlCellTypeVisible).Copy
 

Forum statistics

Threads
1,136,211
Messages
5,674,425
Members
419,508
Latest member
trinstrick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top