Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: VBA intersect function for rows and column

  1. #11
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0
    thanks for your time and efforts. below codes works as intended.
    Code:
    Private Sub txtdelta_AfterUpdate()
    
    Dim vrech As Range
    Dim lColumn As Range
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Cost")
    
    Set lColumn = sh.Range("i1:AZa1").Find(UserForm1.txtdummy.Value, , xlValues, xlWhole)
    
    Set vrech = sh.Range("E4:E250").Find(UserForm1.txtselectedpart.Value, , xlValues, xlWhole)
    If vrech Is Nothing Then
        MsgBox "Row not found"
    ElseIf lColumn Is Nothing Then
        MsgBox "Column not found"
    Else
        Intersect(vrech.EntireRow, lColumn.EntireColumn) = UserForm1.txtdelta.Value
    End If
    End Sub

  2. #12
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    Thanks for the update

    Something like that to deal with the case of the things returning Nothing would have been my best guess, since usually you will want to check for that situation before attempting to use a possible Range object returned from something. Many things that are designed to return a range object, will return a Nothing rather than erroring if they are unable find a range object.
    The Range.Find method is one of them ( …… This method returns Nothing if no match is found……… https://docs.microsoft.com/de-de/off...cel.range.find )
    Without being able to run the macro I could not be sure. I am still puzzled why I could not run that macro in debug mode. Possibly some other special Event coding I don’t know about jumps in when any attempt is made to run a macro in step debug mode. It is an interesting trick to prevent anyone being able to figure out what your coding is doing. Another possibility is that there may be some protection that I don’t know about on the file to prevent anyone messing with the coding.

    Anyway, Glad you got it sorted.


    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:16 PM.
    A Folk, A Forum, A Fuhrer ….

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
  •