Hiding and unhiding rows

jackfox68

Board Regular
Joined
Jan 24, 2010
Messages
121
Hi All,

I have an excel spreadsheet that I use to send updates to a set group of people. After one of my analysts populates the data points they click on my "Run" button and it copies and paste the data into an email. One probelm I have is there are 10 rows I use to update attendance, however i do not always have 10 people out and when it copies the data over to the email it leave alot of white space. I would like it if only one row were visible below the last cell populated. If th cell then become unpopulated it would then hide the cell again. Can this be accomplished using VBA?

Thanks for any help in advance.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Autofilter uses a title row, so the first row (1 in this code) will always be shown. This code assumes that data in column A indicates whether the row will be included and that the columns of importance are A through F.

This code will end with the columns A-F for the rows that had data in column A copied to the clipboard.
Rich (BB code):
    Dim lLastDataRow As Long
    ActiveSheet.AutoFilterMode = False
    lLastDataRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("A1:F" & lLastDataRow).AutoFilter
    Range("A1:F" & lLastDataRow).AutoFilter Field:=1, Criteria1:="<>" 'Show only non-blank rows
    Range("A1:F" & lLastDataRow + 1).Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
 
Upvote 0
Hi Phil,

Thanks for the reply and the code. I will try to intergrate that into what I have now and see how it works. I am not sure it is going to give me the end result I wanted, however:
1. learned something new
2. appreciate the help

I am obviously a NOOB when it comes to VBA/VB, however I was wondering...do you think I should learn VB before learning VBA or if my goal is only to use it with Excel do you think VBA will be sufficient?

Thanks again for your help and I will let you know how I make out.

Brian
 
Upvote 0
If you let me know the range the full attendance cells occupy, I can tailor the code a bit more closely. Some of your current code would also aid in integrating the new code.

VB has more "stuff" than is required for VBA. There is a lot of overlap, but if you are going to be using VBA in office apps, then the extra stiff for VB is not required. You can learn a lot from the code on the forum and the books sold in the main site.
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,890
Members
452,948
Latest member
Dupuhini

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
Back
Top