• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Vba code Error

Code:
Sub STEP8()
   Dim Ary As Variant
   Dim i As Long
   Dim Dic As Object
   Dim Cl As Range
   Dim Wbk1 As Workbook
   Dim Wbk2 As Workbook
   Dim wsh1 As Worksheet
   Dim wsh2 As Worksheet
  
   Application.ScreenUpdating = False
  
  
   Set Wbk1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls")
   Set Wbk2 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Leverage.xlsb")
   Set Dic = CreateObject("Scripting.dictionary")
   With wsh1
   Ary = .Range("B2", .Range("B" & Rows.Count).End(xlUp).Offset(, 6)).Value2
   End With
   For i = 1 To UBound(Ary)
      Dic(Ary(i, 1)) = Ary(i, 7)
   Next i
   With wsh2
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         Cl.Offset(, 5).Value = Dic(Cl.Value)
      Next Cl
   End With
   Application.DisplayAlerts = False
   Wbk1.Close SaveChanges:=True
   Wbk2.Close SaveChanges:=True
   Application.DisplayAlerts = True
  
   Application.ScreenUpdating = True
 
End Sub






this line has been highlighted
Ary = .Range("B2", .Range("B" & Rows.Count).End(xlUp).Offset(, 6)).Value2


and i am getting error while runing the code so plz have a look Sir
 
Leonardo1234 ... hmm?
Have someway Your code in front of You.
Find from there Rows.Count -text.
Move You cursor in front of Rows.Count -text.
Press 'dot' ( it's same 'dot' as in the end of every sentence ).
Repeat above as many times there are Rows.Count -text.
 
A bad copy / paste as the error raises 'cause of wsh1 is nothing !​
Instead of a bad use of declaring object variable for yet existing object use directly this existing object !​
 
Sorry Sir but dot in the code till today i have not seen any vba code contains dot i have seen many examples but i think i am not understanding what u mean to say sir so plz help
 
As we are not mind readers just trash this 'code' (as copying / pasting is very not coding !)
and restart from here (see in particular How to get the Best Results at Chandoo.org) :​
 
Leonardo1234
'dot'
--- with writing 'dot' ends a sentence.
--- with those parts in code .. it would tell to the code to which sheet it will refer.
and ... without real Execl- file even that cannot verify ( and I cannot verify that even with file! )
 
Back
Top