Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Sub Arrays()
- 'Dimensions
- Dim arComments As Variant
- Dim sht As Worksheet
- Dim LastRow As Long
- Dim LastColumn As Long
- Dim ArrayRange As String
- Dim i As Long
- Dim shtData As Worksheet
- Dim stringToFind As String
- 'Set variables
- Set sht = ThisWorkbook.Worksheets("Comments")
- Set shtData = ThisWorkbook.Worksheets("Data")
- 'Get last row for comments and data sheet
- LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
- LastRowData = shtData.Cells(shtData.Rows.Count, "A").End(xlUp).Row
- 'Set the size of the array
- ArrayRange = "A2" & ":J" & LastRow
- 'Define array of comments
- arComments = Sheets("Comments").Range(ArrayRange).Value
- 'Start looping through the IDs from row 4
- For i = 4 To LastRowData
- 'Define string to find
- stringToFind = Sheets("Data").Range("A" & i).Value
- 'Is stringToFind found in the first column of arComments array
- '#################### How do I do this? #########################
- 'if found, populate column B to J in Data sheet with arComments array values
- Debug.Print "Its working"
- End If
- 'if not found, go to next row on data sheet and repeat checks
- Next i
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement