Copied data to another sheet how to change values of rows

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi, good afternoon. I have got the code below where I copy data from one sheet to another but in row B the data in this is 13 numbers but it comes up as +23555 for example how can I change the value to this to show as the 13 digit number? also in Row Q is the date as 15/05/2019 but when copied over it comes up as 43233 how can I change this to date format automatically in the code for when transferred? Hope you can help please.

Code:
With copySheet
    .Range(.Cells(2, "A"), .Cells(.Cells(Rows.Count, "A").End(xlUp).Row, "BE")).Copy
  End With
  
  pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues

and the below is the whole code
Code:
Private Sub CommandButton2_Click()
  Dim copySheet As Worksheet
  Dim pasteSheet As Worksheet
  Set copySheet = Worksheets("New")
  Set pasteSheet = Worksheets("Combined")

Range("AL2", Range("AL2").End(xlDown)).Copy Range("B2")
Range("B2", Range("B2").End(xlDown)).NumberFormat = "0"
Range("G2", Range("G2").End(xlDown)).Copy Range("D2")
Range("AH2", Range("AH2").End(xlDown)).Copy Range("AI2")
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
With Range("C2:C" & lr)
    .Formula = "=VLOOKUP(B2,Old!B:C,2,FALSE)"
    .Value = .Value
End With
With Range("E2:E" & lr)
    .Formula = "=VLOOKUP(B2,Old!B:E,4,FALSE)"
    .Value = .Value
End With
With Range("AJ2:AJ" & lr)
    .Formula = "=VLOOKUP(LEFT(AI2,LEN(AI2)-2),PC!A:B,2,FALSE)"
    .Value = .Value
    
With copySheet
    .Range(.Cells(2, "A"), .Cells(.Cells(Rows.Count, "A").End(xlUp).Row, "BE")).Copy
  End With
  
  pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    
End With
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I would put this code in after the paste and change the ranges to what you need

Code:
    Sheets("pasteSheet").Select
    Range("H16").Select
    Selection.NumberFormat = "0"
    Range("L16").Select
    Selection.NumberFormat = "d/m/yyyy"
 
Last edited:
Upvote 0
Hi thanks for that, how do I select the whole row is it like...
Code:
Range ("B2:B")
?
 
Last edited:
Upvote 0
Code:
[COLOR=#666666]activesheet[/COLOR][COLOR=#666600].[/COLOR][COLOR=#666666]range[/COLOR][COLOR=#666600]([/COLOR][COLOR=#4070A0]"B1"[/COLOR][COLOR=#666600]).[/COLOR][COLOR=#666666]entirerow[/COLOR][COLOR=#666600].[/COLOR][COLOR=#007020][B]select[/B][/COLOR]
 
Last edited:
Upvote 0
Code:
[COLOR=#666666]activesheet[/COLOR][COLOR=#666600].[/COLOR][COLOR=#666666]range[/COLOR][COLOR=#666600]([/COLOR][COLOR=#4070A0]"B1"[/COLOR][COLOR=#666600]).[/COLOR][COLOR=#666666]entirecolumn[/COLOR][COLOR=#666600].[/COLOR][COLOR=#007020][B]select[/B][/COLOR]

This is what you need if you need column B selected
 
Upvote 0
Hi I need it from like B2 all the way down to B100 for example but It cant be specific as changes daily. Would that be last row or column? Thank you for your help.
 
Upvote 0
that would be the column one that i posted


Code:
[COLOR=#666666][FONT=monospace]activesheet[/FONT][/COLOR][COLOR=#666600][FONT=monospace].[/FONT][/COLOR][COLOR=#666666][FONT=monospace]range[/FONT][/COLOR][COLOR=#666600][FONT=monospace]([/FONT][/COLOR][COLOR=#4070A0][FONT=monospace]"B1"[/FONT][/COLOR][COLOR=#666600][FONT=monospace]).[/FONT][/COLOR][COLOR=#666666][FONT=monospace]entirecolumn[/FONT][/COLOR][COLOR=#666600][FONT=monospace].[/FONT][/COLOR][COLOR=#007020][FONT=monospace][B]select[/B][/FONT][/COLOR]

B is a column, 1 is a row.
 
Last edited:
Upvote 0
Code:
    Sheets("pasteSheet").Select
    [COLOR=#666666][FONT=Verdana]activesheet[/FONT][/COLOR][COLOR=#666600][FONT=Verdana].[/FONT][/COLOR][COLOR=#666666][FONT=Verdana]range[/FONT][/COLOR][COLOR=#666600][FONT=Verdana]([/FONT][/COLOR][COLOR=#4070A0][FONT=Verdana]"B1"[/FONT][/COLOR][COLOR=#666600][FONT=Verdana]).[/FONT][/COLOR][COLOR=#666666][FONT=Verdana]entirecolumn[/FONT][/COLOR][COLOR=#666600][FONT=Verdana].S[/FONT][/COLOR][COLOR=#007020][FONT=Verdana][B]elect[/B][/FONT][/COLOR]
    Selection.NumberFormat = "0"
    Range("L16").Select
    Selection.NumberFormat = "d/m/yyyy"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

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