Hi all,
I have a VBA macro which had been working fine until recently. Now I'm getting the following error message: "Run time error 1004: "The information cannot be pasted because the copy area and paste area are not the same size or shape...". Can you help me? Below is my code:
Sub GetSummitData()
Dim strSQL As String
Dim rs As Recordset
Dim rsDesk As Recordset
Dim I As Integer
Dim intYear As Integer
Dim intCurYear
Sheets("Sheet1").Select
Range("AA:AD").Select
Selection.Copy
Sheets("Summit").Select
lngRow = 3
intYear = Year(Now)
' intYear = 2008
intCurYear = Year(Now)
datCurWeek = Now - Weekday(Now) + 2
strSQL = "SELECT DISTINCT Summit.Desk FROM Summit"
Set rsDesk = db.OpenRecordset(strSQL)
rsDesk.MoveFirst
I = 2
While Not rsDesk.EOF
Sheets("Summit").Cells(1, I).Select
Sheets("Summit").Paste -> 'Failing at this line
Sheets("Summit").Cells(1, I) = rsDesk(0)
I = I + 4
rsDesk.MoveNext
Wend
'more code below
End Sub
Thanks,
B.
I have a VBA macro which had been working fine until recently. Now I'm getting the following error message: "Run time error 1004: "The information cannot be pasted because the copy area and paste area are not the same size or shape...". Can you help me? Below is my code:
Sub GetSummitData()
Dim strSQL As String
Dim rs As Recordset
Dim rsDesk As Recordset
Dim I As Integer
Dim intYear As Integer
Dim intCurYear
Sheets("Sheet1").Select
Range("AA:AD").Select
Selection.Copy
Sheets("Summit").Select
lngRow = 3
intYear = Year(Now)
' intYear = 2008
intCurYear = Year(Now)
datCurWeek = Now - Weekday(Now) + 2
strSQL = "SELECT DISTINCT Summit.Desk FROM Summit"
Set rsDesk = db.OpenRecordset(strSQL)
rsDesk.MoveFirst
I = 2
While Not rsDesk.EOF
Sheets("Summit").Cells(1, I).Select
Sheets("Summit").Paste -> 'Failing at this line
Sheets("Summit").Cells(1, I) = rsDesk(0)
I = I + 4
rsDesk.MoveNext
Wend
'more code below
End Sub
Thanks,
B.