V
V
Vadim Timoshenko2017-10-14 16:24:16
Visual Basic
Vadim Timoshenko, 2017-10-14 16:24:16

How to copy only cell values?

Sub m()
    For i = 1 To Sheets.Count
        If Sheets(i).Name <> "Общий" Then
           myR_Total = Sheets("Общий").Range("A" & Sheets("Общий").Rows.Count).End(xlUp).Row
           myR_i = Sheets(i).Range("A" & Sheets(i).Rows.Count).End(xlUp).Row

           If i = 1 Then
            Sheets(i).Rows("1:" & myR_i).Copy Sheets("Общий").Range("A" & myR_Total)
           Else
            Sheets(i).Rows("2:" & myR_i).Copy Sheets("Общий").Range("A" & myR_Total)
           End If

        End If
    Next
End Sub

Please help me correct the macro code.
It works, it only copies formulas from all other sheets into the "General" sheet.
But I need values.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Timoshenko, 2017-10-14
@PbI6A_KuT

Answered here

Sub m()
Set Sh = Worksheets("Общий")
For i = 1 To Sheets.Count
    myR_Total = Sh.Range("A" & Sh.Rows.Count).End(xlUp).Row
    With Sheets(i)
        If .Name <> "Общий" Then
            myR_i = .Range("A" & .Rows.Count).End(xlUp).Row
            j = IIf(i = 1, 1, 2)
            .Rows(j & ":" & myR_i).Copy
            Sh.Range("A" & myR_Total).PasteSpecial Paste:=xlPasteValues
        End If
    End With
Next
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question