Scottie7275
New Member
- Joined
- Jul 27, 2017
- Messages
- 13
Hi,
I have the following code which creates a table in a worksheet based on data copied from another worksheet. However it throws up a syntax error and everything I have tried isn't working.
I want to paste the values but not the formats etc.
Thanks for any help.
Scott
I have the following code which creates a table in a worksheet based on data copied from another worksheet. However it throws up a syntax error and everything I have tried isn't working.
Code:
With Sheets("Data") x = .Cells(1, .Columns.Count).End(xlToLeft).Column
On Error Resume Next
Set rng = .Cells(1, 1).Resize(, x).Find(what:=Sheets("New Product or Supplier").Cells(4, 3).Value, LookIn:=xlValues, lookat:=xlWhole)
On Error GoTo 0
If Not rng Is Nothing Then
.Cells(.Rows.Count, rng.Column).End(xlUp).Offset(1).Value = Sheets("New Product or Supplier").Cells(4, 4).Value
Set rng = Nothing
Else
Dim NextCol As Long
If Sheets("Data").Range("A1").Value = "" Then
NextCol = 1
Else
NextCol = Sheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column + 1
End If
Sheets("New Product or Supplier").Range("C4").Copy Sheets("Data").Cells(1, NextCol).PasteSpecial xlPasteValuesAndNumberFormats
Sheets("New Product or Supplier").Range("D4").Copy Sheets("Data").Cells(2, NextCol).PasteSpecial xlPasteValuesAndNumberFormats
I want to paste the values but not the formats etc.
Thanks for any help.
Scott