Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: VBA intersect function for rows and column

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0

    VBA intersect function for rows and column

    i am writing code to update spreadsheet cell value with intersect function. i have below code that search UserForm3.txtchangenumber in range I1 to AZA1 (worksheet "Cost") and search userform1.txtselectedpart in range E4 to E250(worksheet "Cost"). i would like to populate cell in (worksheet "Cost") when both search intersect by using intersect function.

    below is code what i have right now. but it gives me run time erroe 1004 method range of object _global failed.

    can you pl help me to understand what is error by correcting below code.



    Code:
    [CODE=vba]Private Sub txtdelta_AfterUpdate()
    
    
    
    Dim vrech As Range
    
    Dim lColumn As Range
    
    Dim sh As Worksheet
    
    Set sh = ThisWorkbook.Sheets("Cost")
    
    
    
    
    
    'Dim colonne As Long
    
            'colonne = Me.ComboBox1.Value
    
    Set lColumn = sh.Range("i2:AZa2").Find(UserForm3.txtchangenumber, , xlValues, xlWhole) 'LookIn:=xlValues)
    
    Set vrech = sh.Range("E4:E250").Find(UserForm1.txtselectedpart, , xlValues, xlWhole) 'LookIn:=xlValues)
    
    
    
    
    
         Intersect(Range("vrech"), Range("col")) = UserForm1.txtdelta.Value
    
    
    
    
    
    
    
    End Sub

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,453
    Rep Power
    10
    Hi
    What line errors?
    ( When it errors, select Debug, and the line that errors should be highlighted in yellow)
    Alan

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm 9wlhQrYJP3M
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg
    https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg
    https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg
    https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg. 9C-br0lEl8V9xI0_6pCaR9
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg. 9bl7m03Onql9xI-ar3Z0ME
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg. 9gdrYDocLIm9xI-2ZpVF-q
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg. 9id_Q3FO8Lp9xHyeYSuv1I
    https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm 9wlhQrYJP3M
    ttps://www.youtube.com/watch?v=LP9fz2DCMBE
    https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg
    https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg. 9wdo_rWgxSH9wdpcYqrvp8
    ttps://www.youtube.com/watch?v=bFxnXH4-L1A
    https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG
    https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg
    ttps://www.youtube.com/watch?v=GqzeFYWjTxI
    https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 11-30-2023 at 03:20 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  3. #3
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0
    Last edited by DocAElstein; 10-26-2023 at 12:20 PM.

  4. #4
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,453
    Rep Power
    10
    Sounds like there is no range returned by
    Intersect(Range("vrech"), Range("col"))
    can you upload a workbook example or give a link to a workbook example

    ( BTW. it will not explain the problem, but you should be doing
    Intersect(Range("vrech"), Range("col")).Value = UserForm1.txtdelta.Value
    usually VBA "geusses" that you mean that, but to be on the safe side, I personally would not rely on VBA geussing correctly )

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=SIDLFRkUEIo&lc=UgzTF5vvB67Zbfs9qvx4AaABAg
    https://www.youtube.com/watch?v=v_1iqtOnUMg&lc=UgxLtKj969oiIu7zNb94AaABAg
    https://www.youtube.com/watch?v=f7xZivqLZxc&lc=Ugxq4JHRza_zx3sz0fx4AaABAg
    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=LuAipOW8BNQ&lc=Ugz0Uy2bCSCTb1W-0_14AaABAg
    https://www.youtube.com/watch?v=ITI1HaFeq_g&lc=Ugx12mI-a39T41NaZ8F4AaABAg.9iDQqIP56NV9iFD0AkeeJG
    https://www.youtube.com/watch?v=vXyMScSbhk4&lc=Ugxa2VYHMWJWXA6QI294AaABAg. 9irLgSdeU3r9itU7zdnWHw
    https://www.youtube.com/watch?v=tPRv-ATUBe4&lc=UgzFkoI0n_BxwnwVMcZ4AaABAg
    https://www.youtube.com/watch?v=LuAipOW8BNQ&lc=Ugz0Uy2bCSCTb1W-0_14AaABAg.9htChVuaX9W9htG01cKBzX
    https://www.youtube.com/watch?v=LuAipOW8BNQ&lc=Ugw6UrV69zpeKvLOeOV4AaABAg. 9ht16tzryC49htJ6TpIOXR
    https://www.youtube.com/watch?v=LuAipOW8BNQ&lc=UgwMKwGZpDjv7vi7pCx4AaABAg
    https://www.youtube.com/watch?v=LuAipOW8BNQ&lc=Ugw6UrV69zpeKvLOeOV4AaABAg. 9ht16tzryC49htOKs4jh3M
    https://www.youtube.com/watch?v=LuAipOW8BNQ&lc=UgxVW-am20rQ5GFuJ9F4AaABAg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 10-26-2023 at 12:25 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  5. #5
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0
    please find below link,
    there are 2 forms. 2nd form gets value from userform3 when you select and click cost updates buttons. i am looking for intersect values from userform3. txtchangenumber and userform1.txtselectpart number in cost spreadsheet updates
    https://www.dropbox.com/s/095zbzry2l...est2.xlsm?dl=0
    Last edited by DocAElstein; 07-16-2020 at 03:39 PM. Reason: Link

  6. #6
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,453
    Rep Power
    10
    I can't find your
    Private Sub txtdelta_AfterUpdate()
    where is it?
    ( I dont have much experience with UserForms, so maybe that macro is somewhere that I am not familiar at loooking in )
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  7. #7
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0
    it is on Form1 under cost lable
    cost.JPGcost.JPG

  8. #8
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,453
    Rep Power
    10
    I cant find those named ranges either, and in fact there is no sheet with the name "cost" , so I expect you gave me the wrong file.... or my ignorance in UserForms is showing up, because I still cant see how to get at that macro...
    The file has a worksheet with the name Form, but there are two UserForms, UserForm2 and UserForm3

    I appologise if it is down to my ignorance and lack of experience with such files.
    I know VBA quite well
    I do have some Userforms of my own and I know how to get at all the coding behind them, but I still can't find your
    Private Sub txtdelta_AfterUpdate()

    I cant see anything like your last screenshots anywhere in either the worksheets or in the VB Editor of the file ylou have given.... ( The file I have from you has the name Part tracker test2.xlsm )




    According to my ( limited ) knowledge of VBA if I have a code line like this
    ThisWorkbook.Sheets("Cost")
    then I must have a worksheet with a tab name of "Cost" or else that code line will error

    I think also, that I must see in the Names manager the named ranges of "vrech and "col" or else
    Range("vrech")
    and
    Range("col")
    will error.

    But once again, maybe in my ignorance, I am missing something obvious....
    Last edited by DocAElstein; 07-16-2020 at 04:27 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  9. #9
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0
    please find below updated link,
    https://www.dropbox.com/s/58c45t68hh...est1.xlsm?dl=0
    sorry for incorrect file.

  10. #10
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,453
    Rep Power
    10
    I think I am out of my depth on this one due to my lack of experience with user forms….
    If I try to step through the macro
    Private Sub txtdelta_AfterUpdate()
    then a UserForm springs up and nothing else happens.

    I have never experienced anything ever like that before.
    In my experience I can step through a macro to try to find out what and where any problem is.
    If I try to do that with your macro , it does not let me step through it. Instead a UserForm pops up.

    So I am at a loss on how to go further . Sorry
    I don’t know how to find a problem in a macro that I can’t seem to run.
    Hope someone else can help.

    Alan
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

Similar Threads

  1. Transpose rows to column and join table
    By Agoyman in forum Excel Help
    Replies: 1
    Last Post: 04-23-2019, 09:56 AM
  2. Replies: 9
    Last Post: 02-01-2017, 06:04 PM
  3. Function Code for getting Column Letter from Column Number
    By DocAElstein in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 08-23-2014, 02:27 AM
  4. VBA To Delete Rows Based On Value Criteria In A Column
    By jffryjsphbyn in forum Excel Help
    Replies: 1
    Last Post: 08-15-2013, 12:45 PM
  5. Delete unwanted rows & column
    By sanjeevi888 in forum Excel Help
    Replies: 1
    Last Post: 09-30-2012, 08:52 AM

Posting Permissions

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