Hi, I just started learning VBA by watching Youtube videos and reading books. I can't figure out what the issues are with the below codes. what I am trying to accomplish is
1) Copy/Paste range of cells from sheet1 tab to a tab called "Output"
2) Once the data is copied, look through empty cells and shift up so there are no longer empty cells
But I am getting this error: " Compile error: Type Mismatch "
Maybe the order of the codes are wrong? do I need to declare variables before copy/paste? Also, I am not sure what the rules are for having separate sub routines?
Thank you very much for your help in advance!
Sub CopyPasteRange()
Worksheets("Output").Range("A1:C5").ClearContents
Worksheets("Sheet1").Range("A1:C5").Copy
Worksheets("Output").Range("A1:C5").PasteSpecial
End Sub
Sub ShiftValuesToTop()
Dim rei As String
Dim OPsheet As Worksheet
Set OPsheet = ThisWorkbook.Sheets("Output")
For rei = 1 To 3 'colums A to C
OPsheet.Range(Cells(1, rei), Cells(5, rei)). _
SpecialCells(xlCellTypeBlanks).Delete shift:=xlUp
Next rei
MsgBox rei.Cells.Count
End Sub
1) Copy/Paste range of cells from sheet1 tab to a tab called "Output"
2) Once the data is copied, look through empty cells and shift up so there are no longer empty cells
But I am getting this error: " Compile error: Type Mismatch "
Maybe the order of the codes are wrong? do I need to declare variables before copy/paste? Also, I am not sure what the rules are for having separate sub routines?
Thank you very much for your help in advance!
Sub CopyPasteRange()
Worksheets("Output").Range("A1:C5").ClearContents
Worksheets("Sheet1").Range("A1:C5").Copy
Worksheets("Output").Range("A1:C5").PasteSpecial
End Sub
Sub ShiftValuesToTop()
Dim rei As String
Dim OPsheet As Worksheet
Set OPsheet = ThisWorkbook.Sheets("Output")
For rei = 1 To 3 'colums A to C
OPsheet.Range(Cells(1, rei), Cells(5, rei)). _
SpecialCells(xlCellTypeBlanks).Delete shift:=xlUp
Next rei
MsgBox rei.Cells.Count
End Sub