0

I have a workbook with some hidden columns. I have a button which is linked to a macro. The macro selects a range of cells on those hidden columns and copies to the clipboard.

When I paste from the clipboard into a text editor, whitespace characters of some sort are pasted, but I am not seeing any values. Also, I am copying quite a few rows and whatever the whitespace info is, it is not enough to account for all the rows either.

I read one question which has a comment noting that hidden cells are copied to the clipboard - and when pasted into another Excel workbook, they are pasted - but remain hidden.

However my issue is that I need to paste them into a text editor.

If I unhide the columns and then click the button to run the macro, then the cell values are pasted correctly into the text editor.

Current macro code:

Sub Copy_code()
'
' Copy_code Macro
'

'
    Range("G12:G1040").Select
    Selection.Copy
    Range("f9:h9").Select
End Sub
youcantryreachingme
  • 1,065
  • 11
  • 17
  • 1
    In general, you want to [avoid using Select in your code](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – cybernetic.nomad Mar 02 '22 at 23:02
  • What happens if you edit the code to Range("G12:G1040").Copy – LJ01 Mar 03 '22 at 02:39
  • 1
    Just confirming that it happens on my end, too. I've tried unhiding then copying and hiding again but it doesn't work. – VBasic2008 Mar 03 '22 at 03:25
  • @LJ01 - it makes no difference. If I use a text editor that shows symbols representing line breaks and whitespace characters, it shows me a single character representing a line break and then a character representing end of file - in other words, my best guess is that the code in my question and your suggested code both return one line break character. – youcantryreachingme Mar 14 '22 at 02:26

0 Answers0