Because my copy&paste function is being disabled, i would like to create a macro for me to copy&paste when i am using MS Excel and even MS Word.
I try to store all the cells in a string array and then use assignment to paste. I think I can copy most cells in MS Excel.
(Important) However, I don't know how to interact with MS Word file for this case.
Also, to judge which application i would like to paste so i can paste accordingly.
(Less Important) Or, even I can copy from MS Word to MS Excel.
***********************************
Option Explicit
Dim ntRow, ntCol As Integer
Dim strCpy() As String
Sub CpyRnge()
' CpyRnge Macro
' Keyboard Shortcut: Ctrl+Shift+C
Erase strCpy()
Dim i, j As Integer, rngChse As Range
Set rngChse = Selection
ntCol = rngChse.Columns.Count
ntRow = rngChse.Rows.Count
ReDim Preserve strCpy(ntRow, ntCol)
For i = 1 To ntRow
For j = 1 To ntCol
strCpy(i, j) = rngChse(i, j)
Cells(i, j) = strCpy(i, j)
Next
Next
End Sub
Sub PsteRnge()
' PsteRnge Macro
' Keyboard Shortcut: Ctrl+Shift+V
Dim rngPste As Range
Dim i, j As Integer
Set rngPste = Selection
For i = 1 To ntRow
For j = 1 To ntCol
If IsNumeric(strCpy(i, j)) Then
Cells(rngPste.Row + i - 1, rngPste.Column + j - 1) = Val(strCpy(i, j))
Else
Cells(rngPste.Row + i - 1, rngPste.Column + j - 1) = strCpy(i, j)
End If
Next
Next
End Sub
********************************
Bookmarks