need to paste range or rows as values

kxlvba

New Member
Joined
Jun 11, 2006
Messages
43
Hello,
I have about 31 worksheets by name of 1,2,3,4.....31.
Now, I need to find the last entry and from row number 3 to this row I need to paste entries as values. Because there are lookup formulas as well.

I tried using the below mentioned code, but it is not working. Please help.

Chosen 2 because first sheet is INDEX.

Sub update()

Dim ws As Worksheet
Dim kctr, irow As Integer

For kctr = 2 To 32

Set ws = ThisWorkbook.Sheets(kctr)
irow = ws.Cells(Rows.Count, 2).End(xlUp).Row

Rows(irow).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= False, Transpose:=False

kctr = kctr + 1

Next kctr

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello

try

Code:
Sub update()
Dim ws As Worksheet
Dim kctr, irow As Integer

For kctr = 2 To ActiveWorkbook.Sheets.Count
    With Sheets(kctr)
        .Rows("3:" & Cells(Rows.Count, 2).End(xlUp).Row).Copy
        .Range("A3").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End With
Next kctr
End Sub
 
Upvote 0
Thanks,
However this codes does the above changes for all worksheets. There is a cell B3 in each worksheet. How do I further place a condition, by which only if cell B3 is populated or <> "", then only paste that worksheets row as values. Rest of the worksheets with no data should be untouched.
 
Upvote 0
Hello

like this?

Code:
Sub update()
Dim ws As Worksheet
Dim kctr, irow As Integer

For kctr = 2 To ActiveWorkbook.Sheets.Count
    If Not IsEmpty(Sheets(kctr).Range("B3").Value) Then
        With Sheets(kctr)
            .Rows("3:" & Cells(Rows.Count, 2).End(xlUp).Row).Copy
            .Range("A3").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        End With
    End If
Next kctr
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,071
Messages
6,163,741
Members
451,855
Latest member
mcook36155

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top