Looking For VBA Code To Only Show Columns With Data
Jun 9, 2014
I have a table with row headers (in column A) and column headers (in Row 1). Throughout the table there are 1's and blanks depending if the column is applicable to a particular row or not.
I want to write a VBA macro to do the following:
1. Do a Vlookup of column A for a particular user input text string.
2. Only show the row that matches the text string.
3. Only show the columns where there is a 1 associated with the selected row.
Then once that is done I need a separate macro to return the sheet to show all the rows and columns.
I have some code for applying various filters, up to a maximum of five. However, not all five fields need necessarily have any filter but I can't find a way in the vaConditions line to show 'no filter' or 'All'.
I'm interested in comparing the 2 columns of data as attached in the SampleData file, for eg. First customer bought 5 items and customer 2 bought 3 items. I'd like to show the difference which customer 1 bought and customer 2 did not buy. Will need to use that via VBA And also for loop if possible!
Basically, when you select Fred and 4, I want to to display 601, 799, 1023, and 1547 in the columns to the left of where you do the selection. (which is not in the same place as that table at the top of this question.
Basically I have a form where the list can expand and contract so there will always be varying row lengths.
What I would like to see is a drop down list that shows a) the actual populated field and b) a description of the field when the drop down list is present.
I believe this can be done with a combo box however that would be a lot of work.
I've got a problem with organizing my data. I've performed a study with several participants, each of which does several trials with 8 conditions (1,2,3,4,5,6,7, or 8), with each participant doing a condition more than once. I also have a separate column telling me whether they responded correctly or incorrectly (with a 1 or a 0).
I need to find a way to produce a new column to identify whether they got each condition (of the conditions 1,2,3,4,5,6,7, or 8) correct separately, i.e one column for responses to condition 1, one for condition 2 and so on....
It would also be useful if there was a way that once this is done I could summarize their accuracy of responses to each condition.
I've attached an example of my data. excel problem example.xlsx
I have an excel 2003 sheet that collects data from Infopath forms. The forms are to record students who have broken school rules, when, where, repercussions etc. One column shows their class and there is a separate column for each rule broken.
I want to create another sheet to show each class down the rows and the columns to show each school rule. Therefore, each cell would show the number of each particular rule broken for each particular class. I have tried to do countif and sumproduct (if on sheet 1, column B the class is KA and on sheet 1, column M, the rule is bullying = how many times this has occurred).
I have 2 different formulas that I need changed in a similar way.
The first formula is for cell AV11: =SUM(BI11,BP11,BW11,CD11,CK11,CR11,CY11,DF11,DM11,DT11,EA11)+10
Every cell starts off blank.
What I need is for cell AV11 to always start off blank until data is entered into one of the other cells. The problem is that since the sum always needs to be +10 only when data is entered in the other cells, I don't know how to keep 10 from showing in cell AV11 when no data is typed in the other cells.
The other formula is for cell CO39: =(CU8)+3
I pretty much need the same thing. If no data is entered in cell CU8, then I do not want cell CO39 to show the 3.
If there is data in the cell then it is to be left. If there is no data in the cell then I would like to show the value 0.
I have tried using a circular reference, using the formula =IF(ISBLANK(B1),0,B1) and other similar formulas but they dont work as the formula overwrites the data in it.
I am trying to write a code for a dropdown box where only the sheet selected from the dropdown is visible. Then, when you select another option from the dropdown, that sheet is the one visible (and all others are hidden).
I got a table which is used to calculate the financial rent ability of certain projects.
The years are in the columns, so for every year there is an entry for revenues, costs, etc.
The lifetime of the projects differs (sometimes 10 years, 20 years, etc.). So if it is chosen that the lifetime is 10 years, I would like the table to only show (and also use) only the first 10 columns (for 20 years the first 20 columns), etc.Is this possible and if so how?
I downloaded a cool add-in from XL-Logic that lets you select sheets to print. It's great, except that I need to print very hidden sheets and it does not display very hidden sheets. Does anyone know how to modify this code so it will list all sheet including very hidden sheets? And is there a way to make the sheets appear in alphabetical order? I've tried to play with it, but I don't know enough about VB....
I attach a file for you to more easily understand my problem. I have a big table with information, then I would like to summarize this, if all fields for certain "Type" (see file) is blank, then I would like to use another value that I keep as a separate row in the summarize table. But I also need to have it to work if zeros are put in, I need to show that value, that's my biggest problem right now when using sumif forumla.
I have to divide two columns. Sometimes there is a zero in one of the columns. Now, I realize that nothing can be divided by zero, but isn't there a way to show a zero instead of the #ref symbol???
A recent message prompted me to complete a project to show all modules and subroutines in a workbook.
As use of VBA to manipulate the VB Editor is a recurring issue I thought it a good idea to share this.
Option Base 1 Dim WBname As String Dim ws As Worksheet Dim TitleStr As Variant Dim VBProject As Object Dim ToRow As Long Dim ToCol As Integer Dim ComponentType Dim MyComponent As Object Dim ComponentName As String Dim TypeArray As Variant Dim StdCol As Integer Dim LastLine As Long Dim CurrentLineNumber As Long Dim CurrentLineText As String Sub SHOW_ALL_MODULES() WBname = ActiveWorkbook.FullName On Error Resume Next Set ws = ActiveWorkbook.Worksheets("WB Contents") If Err.Number 0 Then ' sheet not exist....................
For input I have 2 columns: A---B 1---5 3---4 ----- 2---- I need for output column C: C 1 2 3 4 5 It's possible to do that using one or more function ?
I'm looking at trying to view 1 large keyword phrase list of about 40,000 phrases to another large list.
All I want is a macro, I can assign a button to. Click it and in a new sheet it shows only the rows of data that are different.
I have tried googling it.
I found 1 that looked very good (Not that I really know anything about coding, but I couldnt get it to work.
I'm using excel 2007. As a note the link was here. [url]
I might as well post the code,, but I just couldn't get it to work, shame, because it sounds like it could be what I was after, I'll post it now, but if anyone can help me with this that would be great
Sub CompareWorksheetRanges(rng1 As Range, rng2 As Range) Dim r As Long, c As Integer Dim lr1 As Long, lr2 As Long, lc1 As Integer, lc2 As Integer Dim maxR As Long, maxC As Integer, cf1 As String, cf2 As String Dim rptWB As Workbook, DiffCount As Long If rng1 Is Nothing Or rng2 Is Nothing Then Exit Sub If rng1.Areas.Count > 1 Or rng2.Areas.Count > 1 Then MsgBox "Can't compare multiple selections!", _ vbExclamation, "Compare Worksheet Ranges" Exit Sub
I saw a great code which compared the values in two columns A and B, data such as A123 and then shows, in another column ie C , things in A and not in B and in another column ie D things in B and not in A.
I have a spreadsheet which has a number of columns populated with a day number and below each day number there are some numbers. What I would like to do is to compare the values for Day1 with Day2, Day 2 with Day 3 etc. Is there a smart way to do this using VBA? I am enclosing an example to show what I would like the macro to do.
1. W1 has data in Column A, while W2 has none in that column (except for the header row of course). 2. W1 has rows that W2 does not have, and vice-versa.
I need code that will compare three columns in these two sheets. If the data in these three columns for a particular row match between the two worksheets, then for that row, I need the macro to copy the column A cell in W1 to the corresponding column A cell in W2. Finally, I would like an 'x' be placed into a W1 column if a match was found for that row.
The two sheets do not have the same number of rows, but the data being compared in the three columns should combine to form a unique row match between the two worksheets.
I have a simple macro that I have been using to hide columns in a very large spreadsheet. Essentially, the user has access to buttons that allow him to choose between a variety of the most commonly used views. For some reason, when I add columns and adjust the code to hide/reveal these columns, I get:
"Run-time error '1004' - Unable to set the Hidden property of the range class"
with the Debugger highlighting the code for "BO:DC". This problem occurs for several of the similar buttons, including toggle buttons, that hide/reveal columns. I am aware that custom views can be created in the drop-down menu, but I wanted to keep these buttons on the sheet as a quick means of moving from view to view and toggling columns between hidden and revealed.
I have a userform labels role_selection with 5 checkboxes. Each checkbox with the caption labels as follow: Students, Teachers, Below Average, Customer, and Friend.
In addition, a 3 worksheets each labels as follow: Main page, General, and Final.
The General worksheet has the same name as the 5 checkboxes (Students, Teachers, Below Average, Customer, and Friend).
My question is how can i write a program to determine which checkbox is selected and compare the selected checkbox caption to the names that already existed in the general sheet. If the name exists show that name and hide the rest ...
When you create a userform in the vba editor, then go to another module, then return to the userform, you see the userform object by default and in order to show the code you have to right-click on the userform and select "view code".
How can I make the "view code" view the default view for the form in the VBA editor? (i.e. so that when the form is selected, I am presented with the code, not the object).
I have a spreadsheet where when cell is clicked, it opens the hyperlink dialogue and allows a user to insert a hyperlink into the cell next to it.
Code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Target.Column = 27 And Target.Row > 7 And Target.Row < 401 Then If Application.Dialogs(xlDialogInsertHyperlink).Show Then Target.Cut Target.Offset(, 1) End If End If End Sub
So if the cell AA8 is click it allows the user to insert a hyperlink and the hyperlink is pasted in to the cell AB8.
What I need: Is for the cell AA8 to say "Click to Add Hyperlink" and then once a hyperlink is added AB8 to say in the cell "Hyperlink to Folder".
i want to know how to show the progress of code exceuted in an excel sheet. like when we download a file from web or server it shows the staus of the file transfer.