Syntax error while adding to a list

Boogerbut74

New Member
Joined
Oct 17, 2022
Messages
26
Office Version
  1. 365
Platform
  1. Windows
I am trying to add all the data from cell B3 to the last column with data in row B


VBA Code:
Set devTrack = New ArrayList

' code bellowis brocken

devTrack.Add.Sheets("Historian deviation").Range(. cells(3,B), .Cells(3,Columns.Count.End))

'code above is broken



Set columnrng = Sheets("Deviation tracker").Columns.Count.End(xlToLeft).Offset + 1


For i = 1 To 7

    'If their is a duplicate it delete that row in the historian
    
    Sheets("Historian Deviation").Range("A" & i).Select
    
    If devTrack.Contains(ActiveCell) Then
    
        Dim element As Variant
        For Each element In devTrack
            Debug.Print element
        Next element
    
   ' Sheets("Historian Deviation").Range(.Cells(i, A), .Cells(i, l)).ClearContents
    
   ' This adds the data from historian and adds it to row 3,4,5,6 of the last columb of devtracker sheet and adds 8-24 from the sheet
   
    
    Else

       Range("A" & i).Select
       Selection.Copy
       Sheets("Deviation tracker").Select
       Range("columnrng" & 3).Select
       ActveCell.Paste
       Application.CutCopyMode = False
       
       Sheets("Historian deviation").Select
       Range("B" + i).Select
       Selection.Copy
       Sheets("Deviation tracker").Select
       Range("columnrng" & 4).Select
       ActveCell.Paste
      

       Sheets("Historian deviation").Select
       Range("D" + i).Select
       Selection.Copy
       Sheets("Deviation tracker").Select
       Range("columnrng" & 5).Select
       ActveCell.Paste

       Sheets("Historian deviation").Select
       Range("K1").Select
       Selection.Copy
       Sheets("Deviation tracker").Select
       Range("columnrng" & 6).Select
       ActveCell.Paste

       Range("B8:B28").Select
       Selection.Copy
       Range("columnrng" & 6).Select
       ActveCell.Paste
      



       End If


Next
devTrack.Clear



End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Let's forget about your code for a moment.
Better explain with examples what you want to copy and where you want to paste it.
Use the XL2BB tool to put a minisheet of the example of what you have on the "Historian deviation" sheet. Put another minisheet with the result you want on the "Deviation tracker" sheet.
 
Upvote 0
the rest of my code works and I have no problem with that. the part i need is to add all the data for A3 to last column populated to a list in one of my sheets and how to write it. When i make the array list and the try to add data with this code " devTrack.Add.Sheets("Historian deviation").Range(. Cells(3,B), .Cells(3,Columns.Count.End)) " it give me a syntax error. I am also unable to download thing onto this laptop because I am not the owner of the laptop and my friend does not want XL2BB on his laptop. If you are unable to help because of this I understand.
 
Upvote 0
cell B3 to the last column with data in row B
Row B? :unsure:

So just explain what data you have and what you want to add, because it's not clear to me.
Do you want to add B3, B4, B5, B6 and so on?
Or do you want to add B3, C3, D3, E3 and so on?
But explain with data and examples.
And why do you want to add the data in an array?
What is the end goal?
 
Upvote 0

Forum statistics

Threads
1,215,547
Messages
6,125,461
Members
449,228
Latest member
moaz_cma

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