Multiple Vba Commands On A Single Line
May 19, 2008
Is it possible to have multiple VBA commands on a single line with a separator ( ; or , ) of some kind?
I am trying to keep my code as short as possible (from a scrolling perspective) and would like to have something like the following:
Dim MyArray(1 to 20, 1 to 3)
MyArray(1,1) = "Sheet1" ; MyArray(1,2) = "D8" ; MyArray(1,3) = "D9"
MyArray(2,1) = "Sheet1" ; MyArray(2,2) = "C49" ; MyArray(2,3) = "w3"
MyArray(3,1) = "Sheet1" ; MyArray(3,2) = "A23" ; MyArray(3,3) = "AB12"
MyArray(4,1) = "Sheet1" ; MyArray(4,2) = "Z19" ; MyArray(4,3) = "W12"
MyArray(5,1) = "Sheet1" ; MyArray(5,2) = "Q32" ; MyArray(5,3) = "Q23"
View 9 Replies
ADVERTISEMENT
Mar 30, 2014
I have a multiple line texts I want to convert it in single line like for Example:
The following contents is to be converted in a single line
contents:
[aaaaaaaa] [bbbbbbb]......so on
[cccccccc] [ddddddd]......so on
[eeeeeeee] [fffffffffff]......so on
Result:
[aaaaaaaa] [bbbbbbb] [cccccccc] [ddddddd] [eeeeeeee] [fffffffffff]....so on
View 4 Replies
View Related
Feb 10, 2010
Single coding line into multiple using underscore
How can i break this up
View 3 Replies
View Related
Oct 16, 2007
I import data into an excel spreadsheet where a unique job number may have multiple costs against it. These import as separate lines, repeating the job number.
The data imports on a sheet called 'DataImport'. From that sheet I transfer some of the imported fields onto another sheet.
What I need to be able to do is transfer the job number and a sum of the costs onto the other sheet.
The data is run regularly and I delete all the fields on the DataImport sheet in the macro each time the import is run.
View 9 Replies
View Related
Dec 21, 2007
I have one row per day of the month in column A. each row has one or more cell entries in column B .... to column (variable) Right now I use a formula =concatenate(B2,CHAR(10),C2,CHAR(10),D2.....) for as long as it has to be, but this has its limits and requires a lot of editing as the number of filled cells for each row vary.
would it be possible with some macro code to manage the variable number of cells and then insert verything, wrapped text, in a single cell (can be cell Bx or a cell in a new column added next to the dates column) As soon as everything is in the single cell, the original data cells can be emtied. I can record a macro but that does not allow me to manage the variable number of cells . a small sample file attached.
View 7 Replies
View Related
May 13, 2014
I want to accomplish a few things in one cell. The basics are this:
I want to pull the lowest numbers from a given sample. The sample needs to have a time component (10 lowest out of the most recent 20 results). Those numbers are to be averaged. That average is to be multiplied by .96, then that final yield needs to be truncated to 1 decimal.
Now, I'm not sure this is possible or not. But, if it is, I want to also select the amount of numbers I pull from the sample to average to be based on the sample size itself. For example, if there are 10 results in the sample size, I only want to average the lowest 3 of the 10.
Is it possible to formulate all of these rules into one cell?
View 1 Replies
View Related
Jun 12, 2007
I have 2 cells on the same page of the worksheet that I would like to have a popup box flag if the user has entered a number over 100%. In this example the value is hard coded in cell A41 as 100% and can not be changed by the user. The entry cells are A14 and A15. The code works fine if I comment out one of the Worksheet_Change statements.
Is there a way to have 2 worksheet_Change statements on the same sheet or do I have to combine the if statement. My attempts at this point to combine the if statements have not worked.
Private Sub Worksheet_Change(ByVal Target As Range)
'MsgBox for the % value range READS
Select Case Target.Address
Case "$H$14"
If Range("H14").Value > Range("A41").Value Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "This value cannot exceed 100%.", vbCritical, "ERROR"
End If
Exit Sub
Case Else
Exit Sub
End Select
End Sub
View 3 Replies
View Related
Feb 13, 2014
The code I have below is relevant to this spreadsheet Copy of Invoice test.xlsm
In the code below I marked the script that has issues in red. The code takes the last row and the last column and works from there. This works fine with single commands, however, when I take a cell (based off the last row and the last column) and try to give that cell multiple commands excel sends back an error. When I use this multiple command (see part of code that is marked in red) for a range that is not based off the last column it works fine.
[Code] .....
View 9 Replies
View Related
Mar 30, 2013
I have about 180 workbooks which I need to compile into a Master Schedule.
All the tab 1's are different, these feed into tab 2, which the data has the same formatting throughout. The 2nd tab has the same data for A:F 1 but cells A:2 - F:2 down to row 9 are populated from tab 1, therefore different in each. I am trying to get a Master schedule that lifts the data in the fed cells into a line by line spreadsheet?
Is there a way I can get excel to look at a folder, then every workbook in it, the at the 2nd tab in every workbook, then list the cells as described above? I am not after a consolidation of this data, but a full list?
View 1 Replies
View Related
May 19, 2014
I have this function that works on line 3 and if the conditions are met, the result is 1
=SUMPRODUCT(--(IfColor(B3,$A$76)*(SUMPRODUCT(--(D3D4)))))
Here how it works, if B3 is the same color as the reference cell $A$76 and D3 is different than D4 then the result is 1
I would like this function to work from line 3 to line 60 and return the total of lines where the conditions are met. I'm thinking of a =COUNTIF function but can't get something to work. If there is a simpler way, it's even better. The IfColor is a function I wrote in VBA,
View 9 Replies
View Related
Feb 14, 2014
Difference between these two statements. The first one works perfectly while the second one returns an error. Also why is the best scenario to use IF and Then on a single line?
[Code].....
2nd one with error:
[Code] .....
View 14 Replies
View Related
Dec 8, 2007
i hv following code
(i use generate macro)
my question is how to arrange the code from one line to multiple like :-
following code show in excel macro environment is one striaght line.
' Create new var on yr , and replace 2006 to CY06.
ActiveCell.FormulaR1C1 = _
View 9 Replies
View Related
Apr 16, 2012
Why is the VBA for putting a simple border around a cell so convoluted. For example cell A2:
Code:
Sub CellBorder()
Range("A2").Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
[Code] ........
So many lines to put a simple - single line border (square) around a cell.
View 3 Replies
View Related
Mar 16, 2014
I am trying to count the number of commas in each line of my Excel file. So I first decided to count the total number of rows and then count the number of commas in each row. I wrote this code. But I keep getting an error saying Next without for.
Sub Give_The_Last_Row()
Selection.SpecialCells(xlCellTypeLastCell).Select
LastRow = ActiveCell.Row
[Code]....
View 1 Replies
View Related
Nov 12, 2009
I have to worksheets: Sheet1, Sheet2. In sheet 1, I have some data like this (in first col is 1, second col is a, third col is c etc. ):
1 a b c d
2 e f g h
.
.
.
.
I need in sheet 2 in range A1(only in this range one big text), something like this: a,c,e,g ........ ( row1-col2,row1-col4,row1-col2,row1-col4 ......) ( separated by ","). The number of rows from sheet 1 is variable. The dataf a,b,c,d,e,f,g,h ... is some random text.
View 4 Replies
View Related
Jun 20, 2013
Showed a line chart using 2 vertical axis where the first was a single line along the graph (ie. 42%) then the second data series was a single data point that was above or below the line which easily showed if the result lied above or below the threshold.
How to get a straight line across the body of the just to be used as the theshold line?
View 1 Replies
View Related
Sep 21, 2009
I had the following code that worked great with Excel 2003, but I receive an error with Excel 2007.
Dim Master As Workbook
Set Master = Workbooks("Master.xls")
For Each wb In Workbooks
wb.Activate
If wb.Name Like "S04*" Then _
If Not Range("A2") = Empty Then _
Range(Cells(Rows.Count, 1).End(xlUp), Range("A2")).EntireRow.Copy _
Master.ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1)
Next wb
I receive error 1004 "application defined or object defined error" when it tries to paste to the "Master" sheet using the the above lines.
Is there something in the formatting that has changed with 2007? I'm guessing I have to slightly change the line in bold.
View 9 Replies
View Related
Aug 22, 2008
My basic problem is I compile a newsletter for my company. Many people write me E-mails and i paste their "daily accomplishments" into a template. My question is if there is an easy way to insert bullets at the beginning of each line inside the cell. My company wants it prepared with a certain type. I am attaching a sample.
View 2 Replies
View Related
Jun 10, 2006
I have some code (authored by Dangler) that i want to pull not just one range but also the contents of one specific cell and then copy the range and cell to a line on another spreadsheet.
Question:
f .Cells(i, 8).Value > 0 Then
.Range(Cells(i, 1), Cells(i, 200)).Copy
Sheets("all").Range("a65536").End(xlUp).Offset(1).PasteSpecial (xlValues)
End If
I want to add a single cells contents to the LINE that is being copied .... something like this...
f .Cells(i, 8).Value > 0 Then
.Range(Cells(i, 1), Cells(i, 200)) AND A1.Copy
Sheets("all").Range("a65536").End(xlUp).Offset(1).PasteSpecial (xlValues)
End If
the output would be like this: CELL CONTENTS, RANGE CONTENTS
or
K21, 40012122 400 450 450 50 001 BAGS
View 9 Replies
View Related
May 8, 2006
Find Multiple instances of Numeric Criterion in Row & Return To a Single
Column.
I have a Dynamic Named Range "Data" spanning 10 Columns and many Rows.
Each Row may contain duplicates of the Numeric Criterion.
I would like to find ALL instances of a specific Numeric Criterion across
each single Row in the Dynamic Range "Data" and have the Results returned to
a New Sheet in a single column.
NEW Sheet:
The Numeric Criterion is housed in G5.
The matched criterion should be returned to the New Sheet starting at G7.
Duplicate instances in the same Row should ALL be returned to the same cell
in Column G on the New Sheet.
Sample Data Layout:
Columns I J K L M N O P Q R
Row No.76 1 0 1 1 0 1 1 1 0 1
Row No.77 2 2 3 2 1 2 2 0 0 0
Row No.78 3 3 3 3 3 0 3 0 3 0
Scenario:
Looking for Numeric Criterion 1 (one).
Expected Results - New Sheet:
Row No.7 Column G (Cell G7) 1111111
Row No.8 Column G (Cell G8) 1
In Row 76 of the Sample Data ALL seven Numeric Criterion of 1 (one) should be
returned to the same cell G7.
In Row 77 of the Sample Data there is only one Numeric Criterion of 1 and it
should be returned to cell G8.
View 14 Replies
View Related
Apr 20, 2012
I'm trying to search for a column by looking for a specific column header and then format the entire column in the specific number format desired, but I keep getting an error message with this line.
Code:
With Rows("1:1")
.Find(what:="Go Live Date").Column.NumberFormat = "m/d/yyyy"
End With
View 2 Replies
View Related
Apr 14, 2008
In VBA, is it possible to write to a text file, on 1 single line (without carriage return or line feed) the values of a dynamic array? For instance, I have the array:
Dim my(n) As Double 'n is changeable
my(0) = 0
my(1) = 1
my(2) = 2
.....
I want to write to a text file, like this: Write #filename, my(0), my(1), my(2) '..... until my(n) but n is changing
I want them on 1 line, because I use the other direction (up - down) for other things).
View 2 Replies
View Related
Mar 29, 2002
You must install "Analysis TookPak-VBA" before doing this; check in your Excel's Tools/Add-Ins menu. Paste this long function (see below) in an Excel's worksheet (any cell) and press F9 (calculate) until you see at least 2 identical numbers. Real life's lottery does not have repeating numbers. I can disable this repetition by using cells relation but I want to use just one (1) cell. Any expert wants to challenge? If not, you can use VBA. But it still requires one (1) line of codes.
=RANDBETWEEN(1,50)&" "&RANDBETWEEN(1,50)&" "&RANDBETWEEN(1,50)&" "&RANDBETWEEN(1,50)&" "&RANDBETWEEN(1,50)&" "&RANDBETWEEN(1,50)
View 9 Replies
View Related
Mar 21, 2008
I have a text file containing internet explorer browser history. The file has data in the following format (in Excel all data is in 1 column): ...
View 9 Replies
View Related
May 25, 2014
I'm making a Form with multiple pages and on every page there are atleast 36 Textboxes.
[Amount] [Description] [price]
I want to run a small sub updating the price on changing the amount. My code now looks like this:
Code:
Private Sub TextBox1_Change()
Call UpdatePrice
End Sub
Private Sub TextBox2_Change()
Call UpdatePrice
End Sub
Private Sub TextBox3_Change()
Call UpdatePrice
End Sub
I have to do this on 8 pages, 24 to 36 times, which makes the code extremely long. Is there a better way to do this?
Something like:
Code:
Private Sub TextBox1_Change(), TextBox2_Change() etc...
Call UpdatePrice
End sub
View 2 Replies
View Related
Aug 31, 2012
I have a worksheet entitled 'Data'. In this worksheet there is a table consisting of 4 columns plus relevant data:
TABLE 1:
Project
Benefit Type
Delivered or Enabled
Benefit
PJ1
Financial
Delivered
Saving of $4M over 24 months.
[code]....
I have been trying to create a formula that will enable me to pull data from the 'benefit' column(column D) so that the cell contents populate in a single cell in a table in a different worksheet.
TABLE 2:
Financial - Delivered
Financial - Enabled
Tech - Delivered
Tech - Enabled
Green - Delivered
Green - Enabled
[code]....
So, as an example, I am hoping that a formula can be created which pulls the text from relevant cells in column D when criteria from columns A, B and C are met e.g. Tech benefits that are Delivered in PJ2 would populate cell E3 ('Tech -Enabled') in Table 2 with:
Continued maintenance of hardware.
Increased capacity.
View 1 Replies
View Related
Sep 12, 2012
So the issue I am having is that I have a worksheet with two long rows of value. If the user enters the incorrect value, the program gives a error case of 1004. If and when this error occurs I want the program to send a MessageBox to the user then end the program. The problem that I am running into is that whenever I write On Error Goto... It Goes to the label whenever any runtime error occurs. My belief is that there has to be a way to only check for a runtime error on a single line of code rather than the entire sub.
View 3 Replies
View Related
Feb 7, 2014
Certification and Training tracking.xlsx
I want to create a certification only list on a separate tab of training that has been completed where a certification has been issued (as indicated by a "Y" in the "Certification?" column on the training tracking tab) and then populate from some of the fields vs. all of the fields.
What I have now, only pulls the first occurence, not all occurences. I saw that I could have identified the multiple columns that needed to be populated, but it didn't work either, so I'm fine putting a separate vlookup in each column.
View 6 Replies
View Related
Jan 15, 2013
I am looking to split multiple different entries in a single cell into multiple columns and repeat this for all rows
Example (I have the below in a single Cell as column headers)
NCM Server Mgmt VLAN Site ID
Next Line down is the data (Each row in a single cell)
Enabled 10.10.10.0 50 TEST SITE 1
Enabled 10.10.20.0 50 TEST SITE 2
Disabled 10.10.30.0 50 TEST SITE 3
How I could achieve this as I have a number of projects where this would become useful
I know you can use delimiters but with spaces between the values I just can't fathom a way forward.
View 12 Replies
View Related
Jan 19, 2010
I have excel 2007, i am doing scientific graphing via an X Y scatter plot graph. Is it possible someone could give me step by step instructions on how to fit multiple best fit lines. In particular two lines one for the upper portion data and top portion of curve. The second on the flatter bottom portion ultimately intersecting in the left inner portion of graph. the graph plots appear as a rounded L.
View 9 Replies
View Related