excel - How to copy and paste rows with filtering and hidden columns? -
i trying copy , paste row in spreadsheet has filtering , hidden columns. reason, when filtering on, excel doesn't copy hidden columns , when paste row, omitting hidden columns.
is there workaround problem? maybe secret shortcut copies cells in selection, including hidden ones?
thanks.
easy solution here (you loop through sheet , store indexes of hidden columns, think might take more time making copied sheet)
sub copyhiddencolumns() dim destinationsheet worksheet, tempsheet worksheet, copysheet worksheet set destinationsheet = thisworkbook.worksheets("destsheet") set copysheet = thisworkbook.worksheets("copysheet") copysheet.copy before:=thisworkbook.worksheets(1) set tempsheet = thisworkbook.worksheets(1) tempsheet.usedrange.hidden = false tempsheet.usedrange.copy destination:= destinationsheet.range("a1") application.displayalerts = false tempsheet.delete application.displayalerts = true end sub
obviously, can use specified ranges rather usedrange
, range("a1")
. placed fillers allow code compile
Comments
Post a Comment