Skip to content

Commit f75304e

Browse files
authored
Merge pull request #23 from bskinn/hidden-output
Add controls for output or not of hidden rows/columns
2 parents 4d40aa0 + 67f7ef8 commit f75304e

File tree

3 files changed

+64
-55
lines changed

3 files changed

+64
-55
lines changed

CHANGELOG.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,59 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88

99
### [Unreleased]
1010

11-
...
11+
#### Added
1212

13+
- Hidden rows and columns now are **NOT** exported by default; checkboxes
14+
to enable export of hidden cells (per row and/or per-column) are
15+
now provided
1316

1417
### [1.1.0] - 2019-01-08
1518

1619
#### Added
1720

18-
* New information box on the form indicates the sheet and range of
19-
cells currently set to be exported
20-
* New warning added, if the separator appears in the data to be exported;
21-
this should minimize accidental generation of files that cannot be
22-
used subsequently, due to the excess separator characters
21+
- New information box on the form indicates the sheet and range of
22+
cells currently set to be exported
23+
- New warning added, if the separator appears in the data to be exported;
24+
this should minimize accidental generation of files that cannot be
25+
used subsequently, due to the excess separator characters
2326

2427
#### Changed
2528

26-
* UserForm now reappears in its prior location when closed
27-
and re-opened, instead of always reappearing in the center
28-
of the Excel window.
29-
* Selection of multiple areas now results in an "<invalid selection>"
30-
message in the new information box; and, greying out of the 'Export'
31-
button instead of a warning message after clicking 'Export'
32-
* Selection of entire rows/columns now sets for export the intersection
33-
of the selection and the UsedRange of the worksheet. Selection of an
34-
entire row/column outside the UsedRange of the worksheet gives an
35-
"<invalid selection>" message in the new information box and disables
36-
the 'Export' button
29+
- UserForm now reappears in its prior location when closed
30+
and re-opened, instead of always reappearing in the center
31+
of the Excel window
32+
- Selection of multiple areas now results in an "<invalid selection>"
33+
message in the new information box; and, greying out of the 'Export'
34+
button instead of a warning message after clicking 'Export'
35+
- Selection of entire rows/columns now sets for export the intersection
36+
of the selection and the UsedRange of the worksheet; selection of an
37+
entire row/column outside the UsedRange of the worksheet gives an
38+
"<invalid selection>" message in the new information box and disables
39+
the 'Export' button
3740

3841
#### Fixed
3942

40-
* Userform now disappears when a chart-sheet is selected, and reappears
41-
when a worksheet is re-selected. Userform will silently refuse to open
42-
if triggered when a chart-sheet is active
43-
* Error handling added around folder selection and output file opening
44-
for write/append
43+
- Userform now disappears when a chart-sheet is selected, and reappears
44+
when a worksheet is re-selected; Userform will silently refuse to open
45+
if triggered when a chart-sheet is active
46+
- Error handling added around folder selection and output file opening
47+
for write/append
4548

4649
### [1.0.0] - 2016-01-30
4750

4851
*Initial release*
4952

5053
#### Features
51-
* Folder selection works
52-
* Name, number format, and separator entry work
53-
* Append vs overwrite works
54-
* Modeless form retains folder/filename/format/separator/etc. within a given Excel instance
54+
- Folder selection works
55+
- Name, number format, and separator entry work
56+
- Append vs overwrite works
57+
- Modeless form retains folder/filename/format/separator/etc. within a given Excel instance
5558

5659
#### Limitations
57-
* Exports only a single contiguous range at a time
60+
- Exports only a single contiguous range at a time
5861

5962
#### Internals
60-
* Modest validity checking implemented for filename
61-
* Red text and disabled `Export` button on invalid filename
62-
* No validity checking implemented for number format
63-
* Disabled `Export` button if number format or separator are empty
63+
- Modest validity checking implemented for filename
64+
- Red text and disabled `Export` button on invalid filename
65+
- No validity checking implemented for number format
66+
- Disabled `Export` button if number format or separator are empty

src/UFExporter.frm

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION 5.00
22
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UFExporter
33
Caption = "Export Data Range"
4-
ClientHeight = 4080
4+
ClientHeight = 4770
55
ClientLeft = 45
66
ClientTop = 375
77
ClientWidth = 4560
@@ -386,31 +386,37 @@ Private Sub writeCSV(dataRg As Range, tStrm As TextStream, nFormat As String, _
386386

387387
' Loop
388388
For idxRow = 1 To dataRg.Rows.Count
389-
' Reset the working string
390-
workStr = ""
391-
392-
For idxCol = 1 To dataRg.Columns.Count
393-
' Tag on the value and a separator
394-
workStr = workStr & Format(dataRg.Cells(idxRow, idxCol).Value, nFormat)
395-
workStr = workStr & Separator
396-
Next idxCol
397-
398-
' Cull the trailing separator
399-
workStr = Left(workStr, Len(workStr) - Len(Separator))
400-
401-
' Write the line, with error-handling
402-
On Error Resume Next
403-
tStrm.WriteLine workStr
404-
errNum = Err.Number: Err.Clear: On Error GoTo 0
405-
406-
If errNum <> 0 Then
407-
MsgBox "Unknown error occurred while writing data line", _
408-
vbOKOnly + vbCritical, _
409-
"Error"
389+
' Only output visible rows unless hidden output indicated
390+
If ChBxHiddenRows.Value Or Not dataRg.Cells(idxRow, 1).EntireRow.Hidden Then
391+
' Reset the working string
392+
workStr = ""
410393

411-
Exit Sub
394+
For idxCol = 1 To dataRg.Columns.Count
395+
' Tag on the value and a separator, but only if
396+
' visible or if hidden output indicated
397+
If ChBxHiddenCols.Value Or _
398+
Not dataRg.Cells(idxRow, idxCol).EntireColumn.Hidden Then
399+
workStr = workStr & Format(dataRg.Cells(idxRow, idxCol).Value, nFormat)
400+
workStr = workStr & Separator
401+
End If
402+
Next idxCol
403+
404+
' Cull the trailing separator
405+
workStr = Left(workStr, Len(workStr) - Len(Separator))
406+
407+
' Write the line, with error-handling
408+
On Error Resume Next
409+
tStrm.WriteLine workStr
410+
errNum = Err.Number: Err.Clear: On Error GoTo 0
411+
412+
If errNum <> 0 Then
413+
MsgBox "Unknown error occurred while writing data line", _
414+
vbOKOnly + vbCritical, _
415+
"Error"
416+
417+
Exit Sub
418+
End If
412419
End If
413-
414420
Next idxRow
415421

416422
End Sub

src/UFExporter.frx

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)