Copy data to anothe Excel sheet without formatting vba

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hello.. How can I copy data without formatting? Copy values only


VBA Code:
Sub Bouton1_Cliquer()


    Dim LastRowF1 As Integer
    Dim NextRowF2 As Integer
    Dim RowCount As Integer
    Dim rngF1 As Range
    
'    For my testing
    Dim Feuil1 As Worksheet, Feuil2 As Worksheet
    Set Feuil1 = Worksheets("sheet1")
    Set Feuil2 = Worksheets("sheet2")
    
    With Feuil1
        NextRowF2 = Feuil2.Cells(Rows.Count, 6).End(xlUp).Row + 1
        If NextRowF2 < 7 Then NextRowF2 = 7                             '<--- Change this to the default starting row
        
        LastRowF1 = .Cells(Rows.Count, 2).End(xlUp).Row
        Set rngF1 = .Range(.Cells(7, "D"), .Cells(LastRowF1, "i"))
        RowCount = rngF1.Rows.Count
            
        Feuil2.Cells(NextRowF2, "c").Resize(RowCount, rngF1.Columns.Count).Value = rngF1.Value
        ' Copy Parameters including format
        .Range("f2").Copy Destination:=Feuil2.Cells(NextRowF2, "B").Resize(RowCount)
        .Range("F2").Copy Destination:=Feuil2.Cells(NextRowF2, "j").Resize(RowCount)
         .Range("a2").Copy Destination:=Feuil2.Cells(NextRowF2, "i").Resize(RowCount)
         .Range("c4").Copy Destination:=Feuil2.Cells(NextRowF2, "k")
         Range("a2").Select
    End With
    
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:

VBA Code:
Sub Bouton1_Cliquer()
  Dim LastRowF1 As Integer
  Dim NextRowF2 As Integer
  Dim RowCount As Integer
  Dim rngF1 As Range
  
  '    For my testing
  Dim Feuil1 As Worksheet, Feuil2 As Worksheet
  Set Feuil1 = Worksheets("sheet1")
  Set Feuil2 = Worksheets("sheet2")
  
  With Feuil1
    NextRowF2 = Feuil2.Cells(Rows.Count, 6).End(xlUp).Row + 1
    If NextRowF2 < 7 Then NextRowF2 = 7                             '<--- Change this to the default starting row
    
    LastRowF1 = .Cells(Rows.Count, 2).End(xlUp).Row
    Set rngF1 = .Range(.Cells(7, "D"), .Cells(LastRowF1, "i"))
    RowCount = rngF1.Rows.Count
        
    Feuil2.Cells(NextRowF2, "c").Resize(RowCount, rngF1.Columns.Count).Value = rngF1.Value
    ' Copy Parameters without format
    Feuil2.Cells(NextRowF2, "B").Resize(RowCount).Value = .Range("f2").Value
    Feuil2.Cells(NextRowF2, "j").Resize(RowCount).Value = .Range("F2").Value
    Feuil2.Cells(NextRowF2, "i").Resize(RowCount).Value = .Range("a2").Value
    Feuil2.Cells(NextRowF2, "k").Value = .Range("c4").Value
    
    Range("a2").Select
  End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,814
Messages
6,181,120
Members
453,021
Latest member
Justyna P

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