Results 1 to 3 of 3

Thread: Format as number

  1. #1
    Board Regular
    Join Date
    Sep 2018
    Posts
    132
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Format as number

    I know to format a cell as a number it should look something along these lines:

    Code:
    Columns("D:K").Select
    Selection.NumberFormat = "#.00"
    I have the following, and would like values in E:K of copied values to format as number in the following section.

    Code:
    WS1.Range(WS1.Cells(c.Row, "E"), WS1.Cells(c.Row, "K")).Copy
    WS2.Cells(lr2, "E").PasteSpecial Paste:=xlPasteValues
    Code:
    Function Copy()
    
    
    Dim WS1 As Worksheet, WS2 As Worksheet, lr1 As Long, lr2 As Long, c As Range
    Application.ScreenUpdating = False
    Set WS1 = Worksheets("ABR")
    Set WS2 = ActiveSheet
    
    
    
    lr1 = WS1.Cells(Rows.Count, "M").End(xlUp).Row
    lr2 = 8
    For Each c In WS1.Range("M1:M" & lr1)
        If c.Value = "Not Exported" Then
            WS1.Range(WS1.Cells(c.Row, "A"), WS1.Cells(c.Row, "C")).Copy
            WS2.Cells(lr2, "B").PasteSpecial Paste:=xlPasteValues
            
            
            WS1.Range(WS1.Cells(c.Row, "E"), WS1.Cells(c.Row, "K")).Copy
            WS2.Cells(lr2, "E").PasteSpecial Paste:=xlPasteValues
            
            lr2 = WS2.Cells(WS2.Rows.Count, "B").End(xlUp).Row + 1
            c.Value = "Exported"
        End If
    Next c
    
    
    
    
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    End Function

  2. #2
    Board Regular
    Join Date
    Dec 2015
    Posts
    302
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Format as number

    Code:
    WS1.Range(WS1.Cells(c.Row, "E"), WS1.Cells(c.Row, "K")).Copy
    WS2.Cells(lr2, "E").PasteSpecial Paste:=xlPasteValuesAndNumberFormats

  3. #3
    Board Regular
    Join Date
    Sep 2018
    Posts
    132
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Format as number

    This is great, thanks!
    Last edited by srosk; May 28th, 2019 at 01:28 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •