+ Reply to Thread
Results 1 to 11 of 11

Loop through Columns and Row

  1. #1
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Loop through Columns and Row

    Hi,

    I want to perform double_click event for combobox, but only for cells in certain columns and rows.

    this is code :

    Please Login or Register  to view this content.
    I have to loop through columns 6 to 67 with step 1, and rows 19 to 409 with step 5, but don't know how (I'm VBA beginner).


    I attached sample, coloured cells needs that double_click event.

    Any help appreciated !!


    Regards, Luka
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Loop through Columns and Row

    I realised only range for this code has to be changed into cells I want :
    Please Login or Register  to view this content.
    Still don't know how to do It though, there are thousand of ranges, I need a loop

  3. #3
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Loop through Columns and Row

    try this...

    Please Login or Register  to view this content.
    Don't forget to click *

  4. #4
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Loop through Columns and Row

    Hi Vikas_Gautam, thanks for response.

    I don't know how you mean that, I'm not quite good at VBA. Tried like this, but not working :

    Please Login or Register  to view this content.
    Can you show what you meant ?

  5. #5
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Loop through Columns and Row

    Hi luka..

    your code...

    Please Login or Register  to view this content.
    Does not have any reference to range or col..?

    then how you are gonna use rows and columns...


    Vikas Gautam

    Dont' forget to click *

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Loop through Columns and Row

    okay I got it..

    you wanna change the position of combo box based on selection in the Respective ranges you have told..

    Try this..

    Please Login or Register  to view this content.
    Don't forget to click *

  7. #7
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Loop through Columns and Row

    Hi luka..your code...
    Does not have any reference to range or col..?
    That's what I'm trying to do. If you look in my post #2, you'll see that I coloured range which has to be changed. OTher than that code works fine this way, but double_click event triggers on every cell that is within that range, but I want to trigger only cells that I mentioned (columns 6:67, rows 19 to 409 step 5)..

    You think that is possible ?
    Last edited by Lukael; 08-16-2014 at 11:12 PM.

  8. #8
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Loop through Columns and Row

    okay I got it..

    you wanna change the position of combo box based on selection in the Respective ranges you have told..
    No, read post #7. Although I tried your code, I get error

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Thumbs up Re: Loop through Columns and Row

    try this then..

    check the attachment..

    its working now..

    actually you or I forgot to declare variables.. used..




    Don't forget to click *
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Loop through Columns and Row

    No, sorry, still not what I want.

    Looks like you don't understand, so I'll explain as simple as possible...Look into your last sample, and look for cells that are coloured. That are the only cells where I want double_click event triggered, nowhere else.

    Your last sample does exactly what mine does in first place - keeps trigging in all other cells too, check It.

  11. #11
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Thumbs up Re: Loop through Columns and Row

    I think,
    Finally I have got the solution...

    it changing the columns from 6 to 67 and rows from 19 to 419 with step 5

    Try running the file in execl 2007 or higher as its giving error in excel 2003

    Don't forget to click *
    Attached Files Attached Files

  12. #12
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Loop through Columns and Row

    The code I used is..

    Please Login or Register  to view this content.
    Don't forget to click *, again

  13. #13
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Loop through Columns and Row

    Yes, that' the right thing !!

    Never knew you can do this :

    If Not Intersect(Target, Rows(r), col)

    Thanks man, much appreciated !!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loop Across Columns...If Blank Cell, Loop Down Rows
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2014, 07:05 PM
  2. Loop Across Columns If Blank Cell Loop Down Rows
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2014, 10:22 AM
  3. Loop through and sum columns
    By Hurricanefly in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-17-2013, 05:39 PM
  4. loop through columns in range and only copy columns that have value of 0
    By gherzberg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2012, 12:55 PM
  5. For each to loop through columns
    By alien3011 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2008, 04:14 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1