Data Transfer

Risque666

New Member
Joined
Nov 23, 2019
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
I have the Spreadsheet with Sheet 2 called Codes & Sheet 1 Called Inserts.
This is the macro I was given to transfer the data to the Inserts sheet but it has the following error as highlighted.

1619659516275.png


The Inserts where I need the Codes to go are Merged & Centered - Is this an issue ?
See below:

1619659745896.png


The spreadsheet is almost there but I am getting stuck just on the transfer of Data.
Can anyone help it shows that the cell is S23 for this example .. is there an easier way to do this.?
 

Attachments

  • 1619659621562.png
    1619659621562.png
    38.9 KB · Views: 3

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
For error you should Check your Inserts Sheet. Are you have correct Data on it? Hover mouse pointer on i and after show value check that cell at Inserts Sheet.
for S23 change code to This:
VBA Code:
Sub TransferData()
Dim i As Long, j As Long, Lr1 As Long, K As Long, Sh1 As Worksheet, Sh2 As Worksheet
Set Sh1 = Sheets("Inserts")
Set Sh2 = Sheets("Codes")
Lr1 = Sh1.Cells(Rows.Count, 1).End(xlUp).Row
For i = Lr1 To 1 Step -1
If Len(Trim(Sh1.Range("A" & i).Value)) = 11 And IsNumeric(Left(Trim(Sh1.Range("A" & i).Value), 4) * 1) Then
Else
Rows(i).Delete
End If
Next i
Lr1 = Sh1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To Lr1 Step 9
Sh2.Range("C10").Value = Sh1.Range("A" & i).Value
Sh2.Range("K10").Value  = Sh1.Range("A" & i + 1).Value
Sh2.Range("S10").Value = Sh1.Range("A" & i + 2).Value
Sh2.Range("C23").Value = Sh1.Range("A" & i + 3).Value
Sh2.Range("K23").Value = Sh1.Range("A" & i + 4).Value
Sh2.Range("S23").Value = Sh1.Range("A" & i + 5).Value
Sh2.Range("C36").Value = Sh1.Range("A" & i + 6).Value
Sh2.Range("K36").Value = Sh1.Range("A" & i + 7).Value
Sh2.Range("S36").Value = Sh1.Range("A" & i + 8).Value
K = K + 1
Sh2.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:/PrintPDFs/Print" & K & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top