-
Notifications
You must be signed in to change notification settings - Fork 2
MAccessors.bas
Contains functions and procedures to simplify access to Excel objects like workbooks, sheets, rows, columns, etc.
created 2020-08-20
by Sergey Frolov ([email protected])
version 0.1 (2020-08-20)
Provided under GNU General Public License
-
Function
getCellValueWithoutOpeningFile()Get cell value without opening external Excel-file -
Function
findRow()Find the first row in the target range with the same values as in the source row for specified columns -
Sub
getArrayFromRow()Put values from target row to target dynamic array. Values can be taken from the first cell of target range to the last cell, of the first row in the range, or from the first N columns only. -
Sub
putValuesToRow()Put any values to row starting from target cell -
Sub
putArrayToRow()Put array values to row starting from index 1 -
Function
lastColumnInTheRow()Find the column index of the last non-empty cell in the row -
Function
lastColumnNameInTheRow()Find the column name of the last non-empty cell in the row -
Function
columnNameByIndex()Get column name by column index -
Function
lastRowInColumn()Find row number for the last non-empty cell in the target column -
Function
lastRowInSheet()Find row number for the last non-empty cell in the entire sheet -
Sub
enableFastCode()Toggle Excel autoupdate mode - SIGNIFICANTLY speed-ups calculations! -
Sub
deleteVisibleRows()Delete all non-hidden rows in the ActiveSheet Can be used in combination with Filters -
Sub
cloneRow()Copy source row and paste it before target row -
Function
match()Wrapper for Application.WorksheetFunction.Match() function -
Function
isOpenWorkbook()Check if workbook open or not -
Sub
deleteAllRowsBelowCell()Delete ALL non-empty rows below the cell -
Sub
findDublicates()Find rows in selected Range with similar values in selected Columns. Row numbers for rows with similar values in mentioned columns will be copied to Clipboard -
Function
getPreviousNonEmptyValue()Get previous non-empty value in the column above the target cell (including the cell value), will be empty if there is no non-empty values above the target cell
Get cell value without opening external Excel-file
fileName - Name of external Excel file
sheetName - target Sheet name
rangeAddress - Range name, where the first cell is a point of our interest
folderOfExcelFile - Optional. The name of folder where the target file is located.
By default current folder will be applied
Value of cell
Find the first row in the target range with the same values as in the source row for specified columns
rowToFind - source/example Row
columnsIDsInRow - list of the column names of the source row separated by coma which will be used for search
inRange - target Range, where to search
columnsIDsInRange - list of the column names of target range separated by coma which will be used for search
Column names can be different for the source and target ranges and will be compared by the order
in columnsIDsInRow and columnsIDsInRange parameters.
Row object
Put values from target row to target dynamic array. Values can be taken from the first cell of target range to the last cell, of the first row in the range, or from the first N columns only.
For example:
getArrayFromRow [C3], myArray, 3
firstCell - Range. Starting cell(s) for taking values
dataArray - Target DYNAMIC array, where the values will be placed
length - Optional. Amount of the values to be taken from the starting cell.
By default values will be taken to the last non-empty cell in the target row.
Put any values to row starting from target cell
firstCell - starting cell
dataArray - ParamArray of values to be placed in row
Put array values to row starting from index 1
firstCell - starting cell
dataArray - Array of values to be placed in row
Find the column index of the last non-empty cell in the row
forRow - Row number
inSheet - Optional. Can be Sheet object, Sheet name or Sheet index.
By default ActiveSheet is used
Column index of the last non-empty cell in the row
Find the column name of the last non-empty cell in the row
forRow - Row number
inSheet - Optional. Can be Sheet object, Sheet name or Sheet index.
By default ActiveSheet is used
Column name of the last non-empty cell in the row
Get column name by column index
columnIndex - Index of the target column
Column name
Find row number for the last non-empty cell in the target column
inColumn - Column name
inSheet - Optional. Can be Sheet object, Sheet name or Sheet index.
By default ActiveSheet is used
Row number for the last non-empty cell in the target column
Find row number for the last non-empty cell in the entire sheet
inSheet - Optional. Can be Sheet object, Sheet name or Sheet index.
By default ActiveSheet is used
The last row number for the last non-empty cell out of all columns in the sheet
Toggle Excel autoupdate mode - SIGNIFICANTLY speed-ups calculations!
set_fast - True for switch-off Excel autoupdate, False - for switch-on
Delete all non-hidden rows in the ActiveSheet Can be used in combination with Filetrs
Copy source row and paste it before target row
copyRow - Source row (values will be copied from this row)
pasteBeforeRow - Target row (values will be pasted to the row BEFORE this row)
inSheet - Optional, ActiveSheet as default value
toSheet - Optional, inSheet as default value
insertRow - If True will add new row before paste, if False - will replce the row before target row with copied values
Wrapper for Application.WorksheetFunction.Match() function
toFind - Value to find
inRange - Range where to find
Returns the relative position of an item in the Range that matches a specified value.
Check if workbook open or not
wbName - Workbook name (without path to file)
True if open, or False if not
Delete All non-empty row BELOW the target cell
fromRange - Target cell Range (the row of the first cell in the Range will be used)
Find rows in selected Range with similar values in selected Columns. Row numbers for rows with similar values in mentioned columns will be copied to Clipboard
inRange - Source range
idInColumns - Column names separated by coma
which together can be treated as unique ID for the row
Get previous non-empty value in the column above the target cell (including the cell value), will be empty if there is no non-empty values above the target cell
forCell - Target cell to start with
inSheet - Optional. Can be Sheet object, Sheet name or Sheet index.
By default ActiveSheet is used
First non-empty value from the target cell or above