VB for hidden columns, trying to get this working

moncode

New Member
Joined
Dec 14, 2016
Messages
8
Hi, I'm trying to get this VB working for hidden columns, it's working for rows (got it somewhere searching in google ) .... I'm not good at this ....


Sub Test1()
Dim x As Long, y As Long
x = ActiveCell.Row
y = ActiveCell.Column
Do
x = x + 1
Loop Until Cells(x, y).EntireRow.Hidden = False
Cells(x, y).Select
End Sub<strike></strike>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,744
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
moncode,

Not sure what you are wanting to achieve here but the column variant of the above code would be...

Code:
Sub Test2()
Dim x As Long, y As Long
x = ActiveCell.Row
y = ActiveCell.Column
Do
y = y + 1
Loop Until Cells(x, y).EntireColumn.Hidden = False
Cells(x, y).Select
End Sub

Hope that helps.
 
Upvote 0

moncode

New Member
Joined
Dec 14, 2016
Messages
8
Thank you for your response but it's not doing what I'm looking for.

Here's an example of my situation : A1 and B1 are merge with a text in it (let's say "Hello mom") then column "C" is hidden I need a VB code that will let me go to D1 and E1 that are also merge to write something down in these merge cell without stopping in C1.

I've tried Offset function but it doesn't ignore the hidden cells

Also I need to do that in several places in the spreadsheet and it's not always in the same place.
 
Last edited:
Upvote 0

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,744
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try...

Code:
Sub Test3()
Dim y As Long
Set AC = ActiveCell


Do
    y = y + 1
    AC.Offset(0, y).Select
Loop Until AC.Offset(0, y).EntireColumn.Hidden = False


End Sub
 
Upvote 0

Forum statistics

Threads
1,195,749
Messages
6,011,436
Members
441,614
Latest member
TiaGtz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top