Copy data to anothe Excel sheet without formatting vba

sofas

Active Member
Joined
Sep 11, 2022
Messages
480
Office Version
  1. 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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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,215,544
Messages
6,125,434
Members
449,223
Latest member
Narrian

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