In this code how can I copy over values only and not formatting. Private Sub…
- User
In this code how can I copy over values only and not formatting. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim wss As Worksheet 'On Click goes to sheet name in column D If Target.Column = [4] Then Set wss = ThisWorkbook.Sheets(Target.Value) 'Set To the sheet named in the clicked cell 'Sheets(Target.Value).Activate wss.Activate 'If the active sheet is named “ADH” If wss.Name = "ADH" Then 'Find the next available row in Column B of the new sheet Dim nextRow As Long nextRow = wss.Cells(Rows.Count, "B").End(xlUp).Row + 1 'Copy the value from Column B of Sheet Providers Worksheets("Providers").Range("B" & Target.Row).Copy wss.Range("B" & nextRow) 'Copy the value of Column C of Sheet Providers to Column A on the same row of Column B Worksheets("Providers").Range("C" & Target.Row).Copy wss.Range("A" & nextRow) End If
- Assistant
To copy over values only and not formatting, change the following two lines:
- Worksheets("Providers").Range("B" & Target.Row).Copy wss.Range("B" & nextRow)
- Worksheets("Providers").Range("C" & Target.Row).Copy wss.Range("A" & nextRow)
to:
- wss.Range("B" & nextRow).Value = Worksheets("Providers").Range("B" & Target.Row).Value
- wss.Range("A" & nextRow).Value = Worksheets("Providers").Range("C" & Target.Row).Value
This will assign the values of the cells rather than copying the cells themselves, so formatting will not be carried over.