Skip to content

Commit

Permalink
Merge pull request #23 from bskinn/hidden-output
Browse files Browse the repository at this point in the history
Add controls for output or not of hidden rows/columns
  • Loading branch information
bskinn authored Sep 20, 2019
2 parents 4d40aa0 + 67f7ef8 commit f75304e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 55 deletions.
65 changes: 34 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,59 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### [Unreleased]

...
#### Added

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

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

#### Added

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

#### Changed

* UserForm now reappears in its prior location when closed
and re-opened, instead of always reappearing in the center
of the Excel window.
* Selection of multiple areas now results in an "<invalid selection>"
message in the new information box; and, greying out of the 'Export'
button instead of a warning message after clicking 'Export'
* Selection of entire rows/columns now sets for export the intersection
of the selection and the UsedRange of the worksheet. Selection of an
entire row/column outside the UsedRange of the worksheet gives an
"<invalid selection>" message in the new information box and disables
the 'Export' button
- UserForm now reappears in its prior location when closed
and re-opened, instead of always reappearing in the center
of the Excel window
- Selection of multiple areas now results in an "<invalid selection>"
message in the new information box; and, greying out of the 'Export'
button instead of a warning message after clicking 'Export'
- Selection of entire rows/columns now sets for export the intersection
of the selection and the UsedRange of the worksheet; selection of an
entire row/column outside the UsedRange of the worksheet gives an
"<invalid selection>" message in the new information box and disables
the 'Export' button

#### Fixed

* Userform now disappears when a chart-sheet is selected, and reappears
when a worksheet is re-selected. Userform will silently refuse to open
if triggered when a chart-sheet is active
* Error handling added around folder selection and output file opening
for write/append
- Userform now disappears when a chart-sheet is selected, and reappears
when a worksheet is re-selected; Userform will silently refuse to open
if triggered when a chart-sheet is active
- Error handling added around folder selection and output file opening
for write/append

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

*Initial release*

#### Features
* Folder selection works
* Name, number format, and separator entry work
* Append vs overwrite works
* Modeless form retains folder/filename/format/separator/etc. within a given Excel instance
- Folder selection works
- Name, number format, and separator entry work
- Append vs overwrite works
- Modeless form retains folder/filename/format/separator/etc. within a given Excel instance

#### Limitations
* Exports only a single contiguous range at a time
- Exports only a single contiguous range at a time

#### Internals
* Modest validity checking implemented for filename
* Red text and disabled `Export` button on invalid filename
* No validity checking implemented for number format
* Disabled `Export` button if number format or separator are empty
- Modest validity checking implemented for filename
- Red text and disabled `Export` button on invalid filename
- No validity checking implemented for number format
- Disabled `Export` button if number format or separator are empty
54 changes: 30 additions & 24 deletions src/UFExporter.frm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UFExporter
Caption = "Export Data Range"
ClientHeight = 4080
ClientHeight = 4770
ClientLeft = 45
ClientTop = 375
ClientWidth = 4560
Expand Down Expand Up @@ -386,31 +386,37 @@ Private Sub writeCSV(dataRg As Range, tStrm As TextStream, nFormat As String, _

' Loop
For idxRow = 1 To dataRg.Rows.Count
' Reset the working string
workStr = ""

For idxCol = 1 To dataRg.Columns.Count
' Tag on the value and a separator
workStr = workStr & Format(dataRg.Cells(idxRow, idxCol).Value, nFormat)
workStr = workStr & Separator
Next idxCol

' Cull the trailing separator
workStr = Left(workStr, Len(workStr) - Len(Separator))

' Write the line, with error-handling
On Error Resume Next
tStrm.WriteLine workStr
errNum = Err.Number: Err.Clear: On Error GoTo 0

If errNum <> 0 Then
MsgBox "Unknown error occurred while writing data line", _
vbOKOnly + vbCritical, _
"Error"
' Only output visible rows unless hidden output indicated
If ChBxHiddenRows.Value Or Not dataRg.Cells(idxRow, 1).EntireRow.Hidden Then
' Reset the working string
workStr = ""

Exit Sub
For idxCol = 1 To dataRg.Columns.Count
' Tag on the value and a separator, but only if
' visible or if hidden output indicated
If ChBxHiddenCols.Value Or _
Not dataRg.Cells(idxRow, idxCol).EntireColumn.Hidden Then
workStr = workStr & Format(dataRg.Cells(idxRow, idxCol).Value, nFormat)
workStr = workStr & Separator
End If
Next idxCol

' Cull the trailing separator
workStr = Left(workStr, Len(workStr) - Len(Separator))

' Write the line, with error-handling
On Error Resume Next
tStrm.WriteLine workStr
errNum = Err.Number: Err.Clear: On Error GoTo 0

If errNum <> 0 Then
MsgBox "Unknown error occurred while writing data line", _
vbOKOnly + vbCritical, _
"Error"

Exit Sub
End If
End If

Next idxRow

End Sub
Expand Down
Binary file modified src/UFExporter.frx
Binary file not shown.

0 comments on commit f75304e

Please sign in to comment.