Using Selection with isempty

largeselection

Active Member
Joined
Aug 4, 2008
Messages
358
I'm having some trouble getting a private sub to initiate and I'm sure it's because I don't have a target specified.

The first part of code puts a checkmark into a cell if it is clicked and that initiates another code called "BUILDER":
Code:
Private sub worksheet_selectionchange(ByVal target As Range)
If IsEmpty(target) Then
        target.Formula = "=CHAR(252)"
        target.Value = target.Value
        With target.Font
            .Name = "Wingdings"
            .FontStyle = "Bold"
            .Size = 8
        End With
 
If Not IsEmpty(target) Then
        Select Case target.Address
Case "$A$3"
Builder "B"

Then there are a lot of "cases". I have another sub which is assigned to a button which basically puts a checkmark in the cells of a selected range if they are visible and the issue is that even though the checkmarks appear, I can't get them to register as a "case" and thus launch the "BUILDER" code. After some reseach I'm sure it is because there is no target specified in my "selectvisible" code. So I can't Call/run/ etc the worksheet_selectionchange code since it doesn't know which targets. So how can I either specify my selection should equal targets? Or can I use something like if not isempty(selection) then select case selection.address?

Here is the code for the selectvisible:
Code:
Sub SelectVisible()
Range("A3:A4083").Select
selection.SpecialCells(xlCellTypeVisible).Select
    selection.Formula = "=CHAR(252)"
    selection.Value = selection.Value
    With selection.Font
        .Name = "Wingdings"
        .FontStyle = "Bold"
        .Size = 8
    End With

PS- All Code is located in the Sheet1 Code.
 
You are right! Sorry about my failure to use correct terminology...one of these days I'll get it.

I do have one giant report and I am ripping pieces off of it to create smaller reports. The smaller reports are much easier to analyze and look at, and this seems to be the fastest way to see what I want to see on the fly.

I could take the reports that I get and put them into a database as you outlined, but then if I want to analyze the data I have to make a pivot table and I don't have as much flexibility with regard to column placement so usually in the past if I've done this I end up having to value out the pivot table and then manually rearranging things.

-The rows do sync up by name or ID number so that's why in my current version it does an index/match when it appends a new report.

-In a finished report (the smaller pieces that are ripped off the giant report) I would probably have 60-70 columns only.

I see the pros+cons to both methods. So it really is about the best way to efficiently select out the columns that I want to rip out of the giant report.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
getting late here, so tomorow I'l take a look at my ideas and then share.

I know you have a sheet that you seelct the columns on for the reports. How is it laid out?
 
Upvote 0
Here is the master report (the giant one):
Excel Workbook
ABCDEFGH
1ABCDEFG
2LABEL 1LABEL 4LABEL 7LABEL 10LABEL 13LABEL 16LABEL 19
3LABEL 2LABEL 5LABEL 8LABEL 11LABEL 14LABEL 17LABEL 20
4LABEL 3LABEL 6LABEL 9LABEL 12LABEL 15LABEL 18LABEL 21
51DATADATADATADATADATADATADATA
62DATADATADATADATADATADATADATA
73DATADATADATADATADATADATADATA
84DATADATADATADATADATADATADATA
95DATADATADATADATADATADATADATA
106DATADATADATADATADATADATADATA
117DATADATADATADATADATADATADATA
128DATADATADATADATADATADATADATA
139DATADATADATADATADATADATADATA
1410DATADATADATADATADATADATADATA
Sheet3


Here is the mini-report generated by copying columns from the giant report:
Excel Workbook
ABCD
16ACE
17copied label 1LABEL 7LABEL 13
18copied label 2LABEL 8LABEL 14
19copied label 3LABEL 9LABEL 15
201Copied Data col ACopied Data col CCopied Data col E
212Copied Data col ACopied Data col CCopied Data col E
223Copied Data col ACopied Data col CCopied Data col E
234Copied Data col ACopied Data col CCopied Data col E
245Copied Data col ACopied Data col CCopied Data col E
256Copied Data col ACopied Data col CCopied Data col E
267Copied Data col ACopied Data col CCopied Data col E
278Copied Data col ACopied Data col CCopied Data col E
289Copied Data col ACopied Data col CCopied Data col E
2910Copied Data col ACopied Data col CCopied Data col E
Sheet3


Here is the sheet where I can select what columns I want to add. It has formulas in which reference the locations of the column labels in the database so that the labels can be flexible if the reports change:
Excel Workbook
ABCD
32CheckMark ColumnLABEL 1 ColumnLABEL 2 ColumnLABEL 3 Column
33X=reference to Label 1=reference to Label 2=reference to label 3
34X=reference to Label 4=reference to Label 5=reference to label 6
Sheet3
 
Upvote 0

Are these 3 statements true?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
1. The Letters in row one of the DATA sheet are the letters that the build code uses to find the column to copy to the REPORT.
<o:p></o:p>
2. A check mark in column A of the selection form is associated with the Letter s in row one of the DATA sheet via the Case statement.
<o:p></o:p>
3. So you either can build the REPORT one column at a time as you enter check marks or have a program that reads all the check marks building the REPORT as it reads through the column of check marks.
<o:p></o:p>
In the selection form do you have a row for every column in the DATA sheet or just a row for every column in the REPORT?
<o:p></o:p>
How do you determine the order of the columns copied from the DATA sheet to the REPORT?
<o:p></o:p>
How do you determine which label is used in the REPORT or do you always use three labels?
<o:p></o:p>
This may seem simple, but why not insert a column in the selecting for and enter the column Letter in it.
<o:p></o:p>
Then you would just pass Target.offset(0,1) to the build program. No test code like the Case statement needed.
Excel Workbook
ABCDE
1CheckMark ColumnDATA ColumnLABEL 1 ColumnLABEL 2 ColumnLABEL 3 Column
2XB=reference to Label 1=reference to Label 2=reference to label 3
3XAA=reference to Label 4=reference to Label 5=reference to label 6
Sheet1

<o:p></o:p>
<o:p></o:p>
 
Upvote 0
Here is a format for building the REPORT I was toying with. Not complete by no means, but just a work-in-progress. Each REPORT format could be saved as a template. Teh REPORT would be built all at once by teh clicking a Buid button.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Excel Workbook
BCDEFGHIJKLMNOPQRST
1Report TitleABC Company
2Report TitleCompare Height and Weight
3Build
4
5Database Column HeaderReport Column HeaderColumn WidthStart Report Column123456789101112ALLStarting MonthReport Build Style
6HeightHeight1JanEvery other month
7WeightWeight2JanEvery other month
8HeightHeight13JulEvery other month
9WeightWeight14JulEvery other month
10Blank826Blank Columns
11AgeAge at Report Date28JanEvery Month
12DOBDOB40DecFreeform
Selecter

<o:p></o:p>
As you entered check marks and other data the Column Headings would show up below the entry form in the order they would appear in the REPORT.
Excel Workbook
CDEFGHIJKLMNOPQRS
28Column12345678
29DATA HeaderHeightWeightHeightWeightHeightWeightHeightWeight
30Report HeaderHeightWeightHeightWeightHeightWeightHeightWeight
31
32Column910111213141516
33DATA HeaderHeightWeightHeightWeightHeightWeightHeightWeight
34Report HeaderHeightWeightHeightWeightHeightWeightHeightWeight
35
36Column1718192021222324
37DATA HeaderHeightWeightHeightWeightHeightWeightHeightWeight
38Report HeaderHeightWeightHeightWeightHeightWeightHeightWeight
39
40Column2526272829302132
41DATA Header(Blank)AgeAgeAgeAgeAgeAgeAge
42Report HeaderAge @ 12/31Age @ 12/32Age @ 12/33Age @ 12/34Age @ 12/35Age @ 12/36Age @ 12/37
Selecter

<o:p></o:p>
<o:p></o:p>
 
Upvote 0
See responses in italics. Thanks!
Are these 3 statements true?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
1. The Letters in row one of the DATA sheet are the letters that the build code uses to find the column to copy to the REPORT.
Yes that is how the builder code identifies which column from the DATA (large report) sheet to copy into the REPORT(small report) sheet.

<o:p></o:p>
2. A check mark in column A of the selection form is associated with the Letter s in row one of the DATA sheet via the Case statement.
Yes again. the code says to use case target.address and then says for each row in column A, Case "$A$3": Builder "B", Case "$A$4": Builder "C", etc.

<o:p></o:p>
3. So you either can build the REPORT one column at a time as you enter check marks or have a program that reads all the check marks building the REPORT as it reads through the column of check marks.
Yes, as it is now it will copy/paste the columns (run the builder code) as each box is clicked (checkmarked). I did have it run at the end by clicking a button until I realized I couldn't get it to add the columns in the order I select them by clicking. It just added them in the order they appeared in the DATA (large report) sheet. I had done that originally by using a long list of If Not isempty($A$3) then Builder "B" ... etc. essentially.

<o:p></o:p>
In the selection form do you have a row for every column in the DATA sheet or just a row for every column in the REPORT?
In the selection from I have a row for every column in the DATA sheet. The rows are labeled by formulas which reference the three labels that I put in the columns for each column in the DATA sheet. That way if I change the labels in the DATA sheet, the identifier on the selection sheet will also change.

<o:p></o:p>
How do you determine the order of the columns copied from the DATA sheet to the REPORT?
This is determined because it runs after each selection is made. So the order they are added is the order they are selected.

<o:p></o:p>
How do you determine which label is used in the REPORT or do you always use three labels?
The labels that are used in the REPORT are copied/pasted from the DATA sheet since the builder code just copies the whole column including the three labels.

<o:p></o:p>
This may seem simple, but why not insert a column in the selecting for and enter the column Letter in it.
<o:p></o:p>
Then you would just pass Target.offset(0,1) to the build program. No test code like the Case statement needed.
That does seem simpler. Again, I'm pretty new at this so I forget things. So would I just call builder Target.offset(0,1) at the end of the checkmark code?


Sheet1

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Arial,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 96px"><COL style="WIDTH: 66px"><COL style="WIDTH: 167px"><COL style="WIDTH: 167px"><COL style="WIDTH: 167px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD></TR><TR style="HEIGHT: 53px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD style="FONT-WEIGHT: bold; FONT-FAMILY: Verdana; TEXT-ALIGN: center">CheckMark Column</TD><TD style="FONT-WEIGHT: bold; FONT-FAMILY: Verdana; TEXT-ALIGN: center">DATA Column</TD><TD style="FONT-WEIGHT: bold; FONT-FAMILY: Verdana">LABEL 1 Column</TD><TD style="FONT-WEIGHT: bold; FONT-FAMILY: Verdana">LABEL 2 Column</TD><TD style="FONT-WEIGHT: bold; FONT-FAMILY: Verdana">LABEL 3 Column</TD></TR><TR style="HEIGHT: 38px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD style="FONT-FAMILY: Verdana; TEXT-ALIGN: center">X</TD><TD style="FONT-FAMILY: Verdana; TEXT-ALIGN: center">B</TD><TD style="FONT-FAMILY: Verdana">=reference to Label 1</TD><TD style="FONT-FAMILY: Verdana">=reference to Label 2</TD><TD style="FONT-FAMILY: Verdana">=reference to label 3</TD></TR><TR style="HEIGHT: 18px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD style="FONT-FAMILY: Verdana; TEXT-ALIGN: center">X</TD><TD style="FONT-FAMILY: Verdana; TEXT-ALIGN: center">AA</TD><TD style="FONT-FAMILY: Verdana">=reference to Label 4</TD><TD style="FONT-FAMILY: Verdana">=reference to Label 5</TD><TD style="FONT-FAMILY: Verdana">=reference to label 6</TD></TR></TBODY></TABLE>

Excel tables to the web >> Excel Jeanie HTML 4
<o:p></o:p>
<o:p></o:p>
 
Upvote 0
I love the selection sheet you've made. Much nicer than the one I have. I actually preferred to have it run the report after making all the selections, I just couldn't get around it adding the columns to the REPORT in the order that they appeared in the DATA sheet. So if I wanted to add column A, C, B, D I can now click on the rows corresponding to A, C, B, D in that order and they will add to the REPORT in that order. Before, when I ran it at the end, because all 4 were checked they were added as A, B, C, D since that is how they appear in the DATA sheet.

I'm a little confused at some of the options to select that you have in your selection. So do I have to keep track of which column I want the data to start in? (from the "start report column")

What does "Report Build Style" mean?

LOVE LOVE LOVE the chart that shows in what order the columns will appear. very nice indeed.
 
Upvote 0
But, you didn't verify any of the statments or answer any of the questions especially if adding a coulmn with the DATA Column Letter would work for you.

To direct the DATA column to a specific REPORT column you could add another column to indicated the REPORT Column

As far as the form I posted, its a work-in-progrees far from complete. So it would be some time before I could get that working well. And I'll be off line in a few days for over a month. But could get somethng to you that you would have to troublr shoot and cutomize.
 
Upvote 0
I think I did respond to your questions. It's in the post right above my last one. I said I answered in italics, but inadvertently made everything italics. I separated out your questions and my answers are directly beneath. Unless I missed some questions or didn't answer some appropriately.

To answer the one specific one you referenced I could add a column with the target address if that makes it easier. Worst case scenario I could hide that on the selection sheet, but I'm willing to do whatever works best.
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,028
Members
452,542
Latest member
Bricklin

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