Results 1 to 10 of 26

Thread: Misc. Leonardo1234 rider@1234 vixer. Highlighting. Simple Early stuff. Avinash Introduction

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #19
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Try this

    Code:
    Sub GetNSEData()
    
        Dim varFilteredSource() As Variant
        Dim rngSourceRange As Range
        Dim lngRow As Long, lngCol As Long
        
        Set rngSourceRange = Workbooks("1.xlsx").Worksheets("Sheet1").Cells(1).CurrentRegion
        lngRow = rngSourceRange.Rows.Count
        ReDim varFilteredSource(1 To lngRow, 1 To 2)
        
        For lngRow = 2 To lngRow
            varFilteredSource(lngRow, 1) = rngSourceRange.Cells(lngRow, 1).Value
            varFilteredSource(lngRow, 2) = rngSourceRange.Cells(lngRow, 2).Value
            For lngCol = 2 To rngSourceRange.Columns.Count - 1
                If rngSourceRange.Cells(lngRow, lngCol).Interior.ColorIndex <> -4142 Then
                    varFilteredSource(lngRow, 2) = rngSourceRange.Cells(lngRow, lngCol + 1).Value
                    Exit For
                End If
            Next lngCol
        Next lngRow
        
        With Workbooks("2.xlsx").Worksheets("Sheet1")
            .Range("M1").Resize(lngRow - 1, 2).Value = varFilteredSource
            .Range("L2").Formula = "=IFERROR(VLOOKUP(B2,$M$2:$N$" & lngRow - 1 & ",2,0),"""")"
            .Range("L2").AutoFill Destination:=.Range("L2:L" & .Cells(Rows.Count, 1).End(xlUp).Row)
            With .Range("L2:L" & .Cells(Rows.Count, 1).End(xlUp).Row)
                .Value = .Value
            End With
            .Range("M1").Resize(lngRow - 1, lngCol - 1).ClearContents
        End With
        Erase varFilteredSource
        Set rngSourceRange = Nothing
        
    End Sub
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugxq4JHRza_zx3sz0fx4AaABAg
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgzMCQUIQgrbec400jl4AaABAg
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgwhVTFaD469mW9wO194AaABAg. 9gJzxwFcnPU9gORqKw5tW_
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugyb8nmKKoXvcdM58gV4AaABAg
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgwvvXcl1oa79xS7BAV4AaABAg
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=UgxvIFArksPprylHXYZ4AaABAg
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugxq4JHRza_zx3sz0fx4AaABAg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 07-11-2023 at 01:04 PM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 9
    Last Post: 05-13-2021, 02:31 PM
  2. Replies: 2
    Last Post: 06-23-2019, 03:30 PM
  3. VBA Range.Sort with arrays. Alternative for simple use.
    By DocAElstein in forum Excel and VBA Tips and Tricks
    Replies: 23
    Last Post: 04-22-2019, 12:31 PM
  4. Class Stuff: VBA Custom Classes & Objects, Class Modules
    By DocAElstein in forum Excel and VBA Tips and Tricks
    Replies: 17
    Last Post: 12-26-2018, 04:35 PM
  5. Free And Simple Excel Based Gantt Chart
    By Excel Fox in forum Download Center
    Replies: 0
    Last Post: 05-02-2013, 03:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •