I am in the middle of tidying up an old piece of code. I've managed to wiggle out a few errors but this one has me flummoxed.
Despite all of the first half of the code working and allowing me to copy the information in their cells to another page consisting of a data table - using the same method to move information from sheet 8 to the 3rd page isn't working.
If I remove Sheets(8).Range("A1").Value
and replace it with A1
, that line runs, so I assume it is a problem within that?
I think there may be a couple errors below this point too in which I'll ask (as once again Error 9 has turned up).
Here is the code below, the erroneous line is:
.Range("B" & RowToPasteTo).Value = Sheets("Config").Range("A1").Value
Sub PostToPipeline()
With ThisWorkbook.Sheets(3)
Dim RowToPasteTo As Long
RowToPasteTo = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
'This defines the variable RowToPasteTo as the next empty line on the Pipeline
.Range("D" & RowToPasteTo).Value = Sheets(2).Range("C4").Value 'This prints the clients name to pipeline.With the left of the '=' being the destination, and the right being the source of information.
.Range("E" & RowToPasteTo).Value = Sheets(2).Range("C5").Value 'This prints TAS Principal
.Range("F" & RowToPasteTo).Value = Sheets(2).Range("C6").Value 'This prints Pillar
.Range("C" & RowToPasteTo).Value = Date
.Range("J" & RowToPasteTo).Value = Date
ThisWorkbook.Sheets(8).Range("A1").Value = ThisWorkbook.Sheets(8).Range("A1").Value + 1 'Sheet makes a permanent variable for reference and adds one with each use.
.Range("B" & RowToPasteTo).Value = Sheets(8).Range("A1").Value
Sheets(1).Range("C4:C11").Select.ClearContents 'Clears the information held in input table.
Range("A1").Select
Sheets(3).Range("A1").Select 'Deselects range
End With
End Sub
What I want is for the value of Cell A1 in Sheet 8 ("Config") to be posted to the next empty cell in column B.