How to Paste as Text and Keep leading zero. I am trying to convert this code to paste as text rather than value but it keeps giving me an error.
Your help will be much appreciated.
Set rngA = .NumberFormat = "@"
then tried
If ra = 1 Then rngB.Resize(, rc).Value = rngA.PasteSpecial : Exit Sub
but nothing worked
Dim rngA As Range
Dim rngB As Range
Dim r As Range
Dim Title As String
Dim ra As Long
Dim rc As Long
On Error GoTo skip:
Title = "Copy Visible To Visible"
Set rngA = Application.Selection
Set rngA = Application.InputBox("Select Range To Copy Then click OK:", Title, rngA.Address, Type:=8)
Set rngB = Application.InputBox("Select Range To Paste (select the first cell only):", Title, Type:=8)
Set rngB = rngB.Cells(1, 1)
Application.ScreenUpdating = False
ra = rngA.Rows.Count
rc = rngA.Columns.Count
If ra = 1 Then rngB.Resize(, rc).Value = rngA.Value: Exit Sub
Set rngA = rngA.Cells(1, 1).Resize(ra, 1)
For Each r In rngA.SpecialCells(xlCellTypeVisible)
rngB.Resize(1, rc).Value = r.Resize(1, rc).Value
Do
Set rngB = rngB.Offset(1, 0)
Loop Until rngB.EntireRow.Hidden = False
Next
Application.GoTo rngB
Application.ScreenUpdating = True
Application.CutCopyMode = False
Exit Sub
skip:
If Err.Number <> 424 Then
MsgBox "Error found: " & Err.Description
End If
Application.ScreenUpdating = True
Application.CutCopyMode = False