Find Copy Paste Special

L

Len

Hi,

The following codes work but does not copy paste special value ( ie
copy value without formula )
Several attempts to modify it but it fails

Extract of codes : -

With Worksheets("BS Grp")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, "A").Value = "10A" Then
iNextRow = iNextRow + 1
.Rows(i).Copy Worksheets("Sheet3").Cells(iNextRow,
"A").PasteSpecial xlPasteValues
End If
Next i
End With
Sheets("Sheet3").Columns.AutoFit

Any help would be appreciated and thanks
I'm excel vba beginner

Regards
Len
 
L

Lars-Åke Aspelin

Hi,

The following codes work but does not copy paste special value ( ie
copy value without formula )
Several attempts to modify it but it fails

Extract of codes : -

With Worksheets("BS Grp")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, "A").Value = "10A" Then
iNextRow = iNextRow + 1
.Rows(i).Copy Worksheets("Sheet3").Cells(iNextRow,
"A").PasteSpecial xlPasteValues
End If
Next i
End With
Sheets("Sheet3").Columns.AutoFit

Any help would be appreciated and thanks
I'm excel vba beginner

Regards
Len


The code seems to work if you just make a new line after the Copy.
Like this:

..Rows(i).Copy
Worksheets("Sheet3").Cells(iNextRow,"A").PasteSpecial xlPasteValues

Hope this helps / Lars-Åke
 
D

Don Guillett

I just tested this fine.

Option Explicit
Sub CopyValues()
Dim i As Long
Dim ilastrow As Long
Dim inextrow As Long
With Worksheets("sheet10")
ilastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To ilastrow
If .Cells(i, "A").Value = "10A" Then
inextrow = inextrow + 1
.Rows(i).Copy
Worksheets("Sheet11").Cells(inextrow, "a") _
.PasteSpecial xlPasteValues
End If
Next i
End With
Sheets("Sheet3").Columns.AutoFit
End Sub
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.
 
L

Len

I just tested this fine.

Option Explicit
Sub CopyValues()
Dim i As Long
Dim ilastrow As Long
Dim inextrow As Long
With Worksheets("sheet10")
    ilastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = 1 To ilastrow
    If .Cells(i, "A").Value = "10A" Then
    inextrow = inextrow + 1
    .Rows(i).Copy
    Worksheets("Sheet11").Cells(inextrow, "a") _
    .PasteSpecial xlPasteValues
    End If
    Next i
    End With
    Sheets("Sheet3").Columns.AutoFit
End Sub
      If desired, send your file to my address below. I will only look if:
      1. You send a copy of this message on an inserted sheet
      2. You give me the newsgroup and the subject line
      3. You send a clear explanation of what you want
      4. You send before/after examples and expected results.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software










- Show quoted text -

Hi All,

Thanks your prompt reply
I didn't realise it just a simple mistake that cause an error in
running my codes
thanks anyway

Regards
Len
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top