LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Strange cut and paste result between worksheets

Another situation where I'm cutting and pasting between different worksheets.
The problem is that for some reason, the data copied FROM the source sheet
(sheet1) becomes values only on the paste sheet (sh) AND the source sheet.
Doesn't make any sense to me. I've checked all my other procedures and
narrowed it down to this one.
Any ideas?

--------------------------------------------
Public Sub SyncAESheet()
Dim ArtCol As Long
Dim i As Long
Dim FirstRow As Variant
Dim LastRow As Variant
Dim CellVal As Long
Dim RowNum As Long
Dim ArtNum As Long
Dim LookUpRng As Range
Dim sh As Worksheet

Application.ScreenUpdating = False

Set sh = ActiveSheet
ArtCol = 1 'means col A

With sh ' This loop finds the first and last rows
i = 1
Do Until FirstRow < Empty
If IsNumeric(.Cells(i, "A")) Then
If .Cells(i, "A").Value 0 Then
FirstRow = i
End If
ElseIf i 50 Then FirstRow = 1
Else: FirstRow = Empty
End If
i = i + 1
Loop
i = FirstRow
Do Until LastRow < Empty
If .Cells(i + 1, "A").Value = "" Then
LastRow = i
ElseIf .Cells(i + 2, "A").Value = "" Then
LastRow = i + 1
Else: LastRow = Empty
i = i + 1
End If
Loop
End With

With sh 'This loop does the replacing
Set LookUpRng = Sheet1.Range("A1:V306")
RowNum = 1

For i = FirstRow To LastRow
ArtNum = sh.Cells(i, ArtCol)
.Cells(ArtNum) = IsText
RowNum = Application.Match(ArtNum, Sheet1.Range("A:A"), 0)
If IsError(RowNum) Then
CellVal = "Error"
End If
Sheet1.Rows(RowNum).Copy
sh.Rows(i).PasteSpecial xlValues
Next i
End With

Application.ScreenUpdating = True

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why this strange result with vlookup Amin Excel Worksheet Functions 3 April 23rd 10 12:16 AM
SUMIF, wrong result, strange behaviour Werner Rohrmoser Excel Worksheet Functions 5 April 23rd 09 05:11 PM
Pivot table strange result prufrock Excel Discussion (Misc queries) 0 February 23rd 07 04:40 PM
Strange result in Excel 2000 ibertram Excel Discussion (Misc queries) 4 November 12th 05 01:48 PM
Switch() causes strange ADO result onedaywhen[_2_] Excel Programming 10 December 13th 04 10:36 AM


All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"