Apply VBA Code To Multiple Columns As Oppose To Just One
Dec 7, 2009
The code below restricts users from inputting anything other than an uppercase "X" in a cell within column N. If the user types a lowercase "x", it would automatically convert it to uppercase. If any other value is entered other than "X", a message box will fire.
The code is specific to column N (column 13). However, I would like to apply this to multiple columns, such as columns 13,14,17,20 .....
View 9 Replies
ADVERTISEMENT
Apr 30, 2008
I have to create autofilters dynamically on x columns based on the selection I make. I created this code but is not working.
LastColumn = Cells. Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Range(Cells(17, 1), Cells(17, LastColumn)).Select
With Selection
.AutoFilter = True
End With
View 2 Replies
View Related
Oct 7, 2009
The following code filters my sheet to show only values less than 0 in column T, (column 20).
View 5 Replies
View Related
Jan 28, 2014
Well we are trying to fetch some data using excel filters. But we are unable to apply filter simultaneously on two excel columns. The problem is explained in the attached sheet. If you have any query/doubt in understanding the whole problem then writ it.
View 5 Replies
View Related
Mar 13, 2014
I want to to copy selected columns of sales data into rows organized by salesperson. I have just started out with VBA and find that I cannot do it myself.
My original data are in the form of the following:
invoice_no
product
sales
qty
total
[Code] .....
I want to display the data in another sheet in the following format:
sales_a
sales_b
sales_c
sales_d
[Code] ...........
View 2 Replies
View Related
Aug 2, 2014
I have amended the code but it's for columns. I want this formatting for entire row 4 only and not for columns. Because it's disturbing my program if there is any data using ':' sign then the same formatting is applied which I don't want.
[Code] .....
The ':' sign is not changing to bold. I want to bold ':' sign too.
How to amend the code for entire row 4?
View 5 Replies
View Related
Jul 29, 2014
I'm using the following VBA code that highlights a selected cell or range of cells when selected (to more easily see what cells I've selected).
[Code] .......
I'd like to use this code on every worksheet within every workbook that I open. Right now I've only inserted the code in "This Worksheet" in a single workbook and that's the only place it works. I tried creating an Add In with the code so that it worked in all workbooks, but it doesn't work.
View 2 Replies
View Related
Dec 14, 2008
Step 1. In Col E a list of amounts will be pasted on a daily basis.
Step2. I need a macro that will look at the last code in Col F and apply the next sequence so $36,543.00 will have OPS003, since i might paste more than one amount in Col E i would like the macro to do the same thing also in Col F. I have a formula in G which will tell me what amounts are outstanding and which have cleared.
AmountCode 12,545.00 OPS001 1,236.00 OPS002 36,543.00
View 9 Replies
View Related
Nov 20, 2007
I recorded a macro in an Excel Workbook which contains 65 worksheets (--this is something received on a quarterly basis for which I have no control). The macro is successful within the workbook created however, a new quarter's data may or maynot have some of the referenced worksheets. 64.9 Waiv - 1 may exists and the others (2, 3, 4, etc) not. The macro fails and prompts for Debug if a worksheet does not exist.
Sheets("64.9 Waiv - 1").Select
Sheets("64.9 Waiv - 2").Select
Sheets("64.9 Waiv - 3").Select
Sheets("64.9 Waiv - 4").Select
Sheets("64.9 Waiv - 5").Select
Sheets("64.9 Waiv - 6").Select
Sheets("64.9 Waiv - 7").Select
Sheets("64.9 Waiv - 8").Select
Sheets("64.9 Waiv - 9").Select
Sheets("64.9 Waiv - 10").Select
Is it possible to alter the macro to look for and only invoke the code if a worksheet past 1 were to exist?
This is what I am requesting the macro do:
Sheets("64.9 Waiv - 1").Select
Range("B9").Select
ActiveWindow.FreezePanes = True
ActiveWindow.SmallScroll ToRight:=5
Range("J8").Select ...............
View 9 Replies
View Related
Aug 4, 2014
How I can apply an IF function for four or more columns. for example: if the value is the same in four or more cells, IF function can type OK, if not something else.
what I am doing is this : =IF(H2=I2=J2=K2=L2,"OK","Not Equal") but I always receive the value"not equal" even when the all cells have the same value. The cells values are found using formula so I did copy and paste value but I received the same result.
View 2 Replies
View Related
Apr 26, 2014
Here is my issue...
Column B has a lot of data within different rows
Column A only has Some empty rows, and some rows with content.
The issue is I am having is I am trying to sort the the rows of column A in Alphabetical order, but Iwant to lock the height or merge the rows so that when I sort them I do not end up with empty spaces or them be un-aligned with Column B. This spreadsheet is too long to go and re-format every cell but here is an example:
A ----- B
John
(blank) ----- this column's
(blank) ----- rows are
(blank) ----- merged
David
(blank) ----- this column's
(blank) ----- rows are
(blank) ----- merged
The cells in B are already at the proper height to be alligned with the names.... but if I try to put the names in alphabetical order then nothing will be alligned.
View 1 Replies
View Related
Mar 5, 2013
I have an excel spreadsheet that performs a particular calculations using a large set of data. However, I have over 1000 sets of data that need to be feed into this sheet and obtain the output calculation. Obviously I don't want to have to copy and paste in each new set of data to obtain my result as this would take a very long time. I am brand new to VBA, so was wondering if there is a way to write code in VBA that will automatically perform these calculations for one data set, save the output into a cell, and then move to the next data set and so on?
View 4 Replies
View Related
Feb 24, 2014
I would like to group some columns to all the sheets that I will have selected. Unfortunately the below code only apply the code to the sheet I am looking at.
Code:
Sub Group()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws.Range("F:Q").Group
End With
Next ws
End Sub
View 3 Replies
View Related
Feb 26, 2008
I havae the following macro which i recorded in Excel. I want this Macro to run after another macro that groups data and creats tabs. The following macro will then add a column and run an array formula. I think this can be done in a loop but i'm not sure how to do it. This is working but takes a long time and times out by the time it reaches the last tab.
Application.Run "TotalHrs"
Columns("I:I").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight
Range("I4").Select
ActiveCell.FormulaR1C1 = "Invoiced Amount"
Range("I5").Select
Columns("I:I").EntireColumn.AutoFit
Selection.FormulaArray = _
"=INDEX(VLookup!R2C2:R242C4,MATCH(RC[-3]&RC[-2],R5C6:R2500C6&R5C7:R2500C7,0),3)*R[3]C[-1]"
Selection.Copy
Range("I6:I1000").Select...................
View 5 Replies
View Related
Dec 31, 2013
I wish to have one conditional format apply to K and L. Presently it's L only where it works.
=OR(K1="",AND(K1="No",L1<>""),AND(K1="OJ",L1=""))
Why when I change the range from =$L:$L to =$K:$L does it not apply to both?
View 3 Replies
View Related
Jun 27, 2014
I have a conditional formatting issue, using VBA.
My conditional formatting code works fine for one column; however, when I try to apply the conditional formatting to two columns, the code only applies to the first column listed. Additionally, I have two sets of "rules" that apply to the same column. One of the "rules" includes two columns. The other rule applies to only one column. I'm not sure if this is my issue, or whether I'm trying to apply the same code to two different columns.
My code is below.
Code that applies to column "M" only...
View 3 Replies
View Related
Apr 14, 2006
I have been given a project to develop a spreadsheet using excel that will take data that is for a whole month, and evaluate by DAY to see if the same doctor was listed as attending two patients in surgery at the same time. If the Doctor's name is the same for two patients within the same timewindow for a certain day, a code is applied to EACH RECORD that the doctor was attending in the code field. If there was NO DUPLICATE patient, a different code is applied in the code field.
The tricky thing about this is:
1) Number of records will vary month-to-month
2) There could be 1-xx patient records where the same doctor is listed and there is overlapping time in the SAME DAY OF THE MONTH.
3) The code applied to multiple patients in the code field applies even if the minutes of overlap = 1 minute.
4) Start/End times and length of the patient visits will vary. (Example - Dr. Jones has two patients on the 15th of the month. The start time for patient 1 is 9:00am and ends at 10:15am. The second patient's start time is 9:30am and end time of 11:00am. Under this situation, the multiple patient code would apply)
Does anyone have any experience evaluating by date, then within a time-window to check for record overlap (doctor name in this case)? There could be 200-1500 records per month, and 100/day to evaluate for overlapping.
View 8 Replies
View Related
Mar 1, 2013
Why can't I apply text functions on strings into the file? For example: can't apply "Text To Columns" delimited by space on "Status Entry Date" column.
View 3 Replies
View Related
May 9, 2013
In the attached file, I need four different passwords for Columns D, E, F, & G Respectively.
I had gone though below link and partially I could able to achieve what I need.
[URL]
However, the problem is at the end of this process we have protected the worksheet as well. This is not feasible for the process what I am working on.
how to apply different password without protecting worksheet.
View 5 Replies
View Related
Aug 22, 2012
I am using this code and it works fine:
Dim MyData As Range
Dim MyResult As Range
Set MyData = Range("E1:E1000000")
Set MyData2 = Range("F1:F1000000")
Set MyResult = Range("J4")
MyResult.Select
Selection.Formula = "=COUNTIFS(" & MyData.Address & ",""=Kim""," & MyData2.Address & ",""=done"" )"
Is there any way I can change the code so that it automatically finds the last cell as Im using Range("E1:E1000000") and Range("F1:F1000000") because there will not be more than 1000000 entries.
View 2 Replies
View Related
Aug 27, 2013
I am trying to come up with a macro that will find rows that contain the words �as % of Revenue� and then calculate and apply the appropriate formula to the actual and budget columns. I have attached a sample of what the source data look like.
The formula divides the category�s total expense by the revenue in row 4. For a complete macro, I would want to also subtract the budget result from the actual result and put its result in the �better (worse)� column. I need to use this on 12 or so different workbooks which is why I�m wanting a macro.
Here is my attempt to accomplish this task; however, I quickly realized it is woefully inadequate because I neither understand how to apply it to the different columns or how to find the next instance of �as % of revenue�).
VB:
Sub Macro1()
'
' Macro1 Macro
'
Range("B10").Select
Cells.Find(What:="as % of Revenue").Activate
Range("B20").Select
ActiveCell.FormulaR1C1 = "=R[-1]C/R10C"
Range("B21").Select
End Sub
View 8 Replies
View Related
Jun 12, 2014
My Excel program (Excel 2010) currently has several columns and each column looks for and pulls data from a specific file on my computer. Then I need to delete any duplicate data entries, count the number of unique entries and track the changes through a chart. I have everything done except I cannot figure out (or find on the internet) a way to search in multiple columns (more than 2) and delete just the duplicate cells. I want to delete the cells in a way where there is one left. For example if the code 12gf is duplicated three time, I want to be left with one 12gf (it doesnt matter what column the original one is left in). Additionally, column length changes and they are not sorted. I have attempted to attach an image of an example file below.
View 14 Replies
View Related
Oct 11, 2007
I have a workbook in which I have 31 sheets. I've also recorded a macro that works great when I run it on one sheet, but it comes up with an error when I try to run it on grouped worksheets. I searched Google, and a few articles I saw said that in order to run a macro on grouped sheets, you have to use loops. I don't know if this is true, but I don't know how to run loops anyway, so. I want to run the macro on 30 of the 31 sheets. I was going to put the code in, but when I did that my post didn't work, so I'm thinking there might be a limit on the length of a post.
View 5 Replies
View Related
Feb 18, 2014
Use filter for 2 columns of a CSV file, column A and Column B for certain words. Say I apply a text filter: contains "word1" or contains "word2" to Column A. Then I get the results. After that, I remove the filter to Column A then apply the same filter to Column B. The thing is, I don't get the results in Column B, instead, I get the cells in Column A wherein Column B is filtered PHOTOS BELOW:
The data that I get for this filter are:
And Word1 you
Word2 is blank
Apply filter to Column B, get the cells filtered in Column A:
The data that get for this filter are from Column A (which are cells filtered from Column B filter)
And Word1 you
Is the blah
Word is all
The results should in a single Column for both filter:
I have more than 100 files that needs to filtered this way, is there any way I can do this automatically?
Here is what the file looks like:
The results I hope would be possible:
Automatically without having to open all the files and have the results of all of it in 1 single Excel file?
----or----
If the above is not possible, open each file and automatically apply the filter into a column in just 1 click and without having to type the same filter for each column.
I found a code to combine all CSV files into 1 Excel file, but half of my files has more than 500k rows and the Excel's limit for rows is around 1million+.
View 9 Replies
View Related
Jul 7, 2006
I am trying to loop through all of my worksheets in my workbook to apply a subotal to each of the sheets. I can get it to work with applying to just one named sheet, but I cannot get the loop to work. The sheets named "data" and "PriceList" do not need the subtotal applied.
Below is the code I am using:
Sub SubTotals()
Dim LastRow As Long
Dim wsDst As Worksheet
View 5 Replies
View Related
Aug 7, 2012
I have a excel sheet from a supplier of mine, that has a mixture of text, and numbers and more importantly "Custom format cells" that have prices in them. I need to apply a multiplication formula to each price, but they are all in different rows and columns, and it will take forever to type a formula into each cell.
Is there a way that if I can select all these cells, to add a global formula that will update all these cells?
View 3 Replies
View Related
Feb 19, 2014
I have to decide if the final answer will be yes or no based on a combination of 4-5 cell values from a single row.
I have attached the details in the excel sheet.
View 4 Replies
View Related
Oct 20, 2009
I am trying to apply data validation to a column of cells using named ranges. However, each row has a unique associated named range. For example:
A_______B
Birds____*
Dogs____*
Cats____*
I can easily apply data validation to these three rows separately using named ranges.
Ie three separate named ranges:
=Birds
=Dogs
=Cats
However, I need a way to quickly apply data validation to column B using different named ranges for each row because there are about 2,000 rows. Is there a way to reference text in the cells of column A that contains the name of the named range? Or maybe a bit of VB code that could do it quickly?
View 3 Replies
View Related
Dec 21, 2006
I work with an excel sheet to produce a list that gets distributed (in hard copy). A problem that I have is sometimes, the list spansmultiple pages, so I have to manually use the page break preview to put the column headings on the first row of each page.
View 4 Replies
View Related
Aug 22, 2006
I have a vertical list of data which is sorted in to "Regions" 1 to 7 there could be up to 25 instances of each Region, but I have no way of knowing.
I want to be able to select each Region and place it in it's own column.
View 9 Replies
View Related