Hello!
This may be kinda picky, but I noticed that in my macro code, if I include the following code (the dots representing the actual script):
On Error GoTo Errorcatch
.
.
.
.
.
Errorcatch:
MsgBox Err.Description
An blank error window pops up. If I remove the above code, the program seems to run well (although it is slow, which may or may not have anything to do with some kind of "hidden error").
I am wanting to confirm that my code has no errors in it, even an error that simply slows down the calculations.
The purpose of the code is to take a big table with lots of gaps...
|
Col1 |
Col2 |
Col3 |
Col4 |
| Text0 |
3 |
64 |
5 |
Text3 |
|
|
|
|
|
| Text1 |
21 |
5 |
77 |
Text4 |
|
|
|
|
|
|
|
|
|
|
| Text5 |
15 |
2 |
33 |
Text6 |
And compress it into a smaller table with no gaps in another worksheet...
|
Col1 |
Col2 |
Col3 |
Col4 |
| Text0 |
3 |
64 |
5 |
Text3 |
| Text1 |
21 |
5 |
77 |
Text4 |
| Text5 |
15 |
2 |
33 |
Text6 |
Here is my code:
Sub Transfer()
'This macro copy-pastes rows from the Sheet2 into Sheet1
'Find rows that contain any value in column A and copy them...
Dim cell As Range
Dim selectRange As Range
On Error GoTo Errorcatch
Sheets("Sheet2").Select
For Each cell In ActiveSheet.Range("A:A")
If (cell.Value <> "") Then
If selectRange Is Nothing Then
Set selectRange = cell
Else
Set selectRange = Union(cell, selectRange)
End If
End If
Next cell
selectRange.EntireRow.Select
selectRange.EntireRow.Copy
'Paste copied selection to the worksheet 'Sheet1' on the next blank row...
Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial _
Paste:=xlPasteValues
Errorcatch:
MsgBox Err.Description
End Sub
Any ideas?
Thanks!