Code To Swap Rows
Jul 19, 2007
I would like to insert a form control (up and down arrows) into a specfied range of cells in a column - ideally the first column. When the form control up or down arrow of the assigned row is clicked it moves that row up or down essentially swapping positions with the row directly above or below. I've seen this functionality in custom excel applications but my searches for code on this topic have been fruitless.
View 5 Replies
ADVERTISEMENT
Jan 31, 2013
Swapping the contents of 2 rows, my code does the operation but it is very slow. Here is my code
Sub swap()
Dim aTemp() As Variant
Dim swap As Boolean
swap = False
Dim row As Integer
row = 19
[Code] .......
View 2 Replies
View Related
Aug 10, 2007
I have a huge xls of names setup as Last Name, First Name in a single column.
Any formula or somehow to change the entire column to read First Name Last Name. No comma.
Example -
Smith, Joe
Brown, Barry
-------------------------
Output desired -
Joe Smith
Barry Brown
View 8 Replies
View Related
May 16, 2008
I am attaching a sample sheet as a reference.
in fact the sheet could contain hundreds if not thousands of rows.
Look at column Player 1, the last 3 characters are AoS.
I want to find any rows where Player 1 has those three characters ( AoS ) and swap them with the contents of the Player 2.
BUT if that swap happens then the following swaps must occur as well:
Contents of Column "Side 1" swaps with Contents of Colum "Side 2"
Contents of Column "Player 1 Pts" swaps with Contents of Column "Player 2 Pts"
Ultimately I want this extended so that is the letters AoS appear in any of the following columns ( Player 4, Player 6, Player 8, Player 10)
the following swaps happens:
Contents of Column "Player 3" swaps with Contents of Column "Player 4"
Contents of Column "Side 3" swaps with Contents of Column "Side 4"
Contents of Column "Player 3 Pts" swaps with Contents of Column "Player 4 Pts"
Contents of Column "Player 5" swaps with Contents of Column "Player 6"
Contents of Column "Side 5" swaps with Contents of Column "Side 6"
Contents of Column "Player 5 Pts" swaps with Contents of Column "Player 6 Pts"
View 4 Replies
View Related
Aug 1, 2006
I want to swap values of two cells. can anyone help me on that? Eg. Cell A1
contains the value 20 & cell A2 contains the value 100. I want 100 on A1 &
20 on A2.
View 9 Replies
View Related
May 12, 2013
I have column AD where there are something like 2,500+ formulas. I would like to change the columns used in the formulas around. By that I mean the first formula is...
Code:
=SUM(AA6-X6)
...and I would like it to be...
Code:
=SUM(X6-AA6)
Now the thing is, the formulas are not continuous, there are breaks where there is a formula to sum say the previous dozen or so for example, then it skips a couple of rows and I have more formulas and then the sum say for the previous dozen for example and so on.
I just want those cells changed with the particular formulas as above.
View 1 Replies
View Related
Jul 30, 2013
I have let say column A and I have the date and name John 1913 all the way down to John 1940.
But what I need is a way to turn it around so A1 starts with John 1940 down to 1913.? If I drag down it counts up but I want it to count down if that makes sense.?
View 6 Replies
View Related
May 21, 2008
Have 5 columns (A1-E1) with different bond data: (respectively)
Coupon, Maturity, Settlement, Price, Yield (asset swap is F1)
Depending on the type of swap I am performing i want the ASWAP (user-created) function to reference different values within the row.
For example: Swap 1 = settlement, maturity, coupon, price, curve
(curve is a user input single number 1-3)
Swap 2 = settlement, maturity, yield, price, curve (yield in place of coup)
Swap 3 = settlement, maturity, yield, 100, curve (100 for par redemption)
etc. I won't type out all the iterations, not necessary.
The way that I want the ASWAP to recognize which Swap# to use is by inputting a number into a cell beside the Aswap column that I can input 1, 2, 3, etc., and then recalculate to get the desired outcome. Want to keep this a static reference as well as the price at par (each owning their own single cell, not a fill down the columns because there are too many).
So assuming G1 is the Swap# input, and H1 is 100...
How do i write a formula that is capable of reading the input in G1 and outputting the proper swap calc.
My gut feeling was along the lines of nested IF's with the corresponding formula... but i won't mess around in futility on here.
Let me know if this is too confusing without me putting up an example.
View 9 Replies
View Related
Nov 29, 2007
Right now I have 2 ranges say A and B. Range A is in a worksheet on row 7 and range B is on the same worksheet row 8. What I want to do is make it so that range B gets pasted in for range A and vice versa so that range A in now in row 8 and range B is in row 7.
View 2 Replies
View Related
Apr 19, 2007
Swap the data between two columns at a time. Here are multiple columns to be swaped in one worksheet and I have many worksheets to work with.
View 9 Replies
View Related
Aug 8, 2008
I am trying to chart a range of dates, for example. I have some boats that are on contract between dates a and b. I would liketo plot several boats with their contract date range. I have tried using a bar chart, but all the lines start at 0. I got it working using an Excel 2007 Stock chart, however, it is in the wrong orientation. I would like to Rotate the Chart 90 degrees, swap the axis, or find a better method all together. I cannot post the spreadsheet as its confidential.
View 2 Replies
View Related
Dec 4, 2012
My pivot table shows Towns as the Row headings and Month as the column headings. When I do a Chart, I get Towns on the X axis and Months as Y. I want the chart to show all my May data in a stacked column, then all my June data in another stacked column, etc. If I pick "Select Source Data" the options are greyed out. What's a mother to do?
View 1 Replies
View Related
Sep 11, 2007
I have an interactive chart displaying stacked area charts for 2006 and 2007
I currently have 2006 in front of 2007, but as the user chooses 1 of 20 units, it will look better to move 2007 in front of 2006
View 4 Replies
View Related
Feb 12, 2014
I am using the code below to "swap" the selected cell values in a column with the ones to the right of the selection. It works fine on unfiltered sheet, but if I apply an Autofilter, it copies both visible and hidden cells, and I only want to swap visible cells. What to modify?
[Code] .....
View 6 Replies
View Related
Jul 24, 2009
I'm trying to write a VBA script which will delete all rows in my Excel spreadsheet where Column I (which contains a status code) does not contain the word "Completed".
At the moment, I'm doing this the other way round: my script is able to search for entries in Column I which contain the status codes "Pending", "Awaiting Authorisation", "In Progress" etc and delete them. The idea is that when all those rows are deleted, I'll only be left with rows which have a status of "Completed". This works fine at the moment. However, the concern is that if a brand new status code is added to the data file, my script would be unable to pick it up and delete it. This is a small sample of the code I'm currently using (which deletes all the rows with statuses other than Completed):
View 4 Replies
View Related
May 25, 2013
The first code hides everything just fine based on the date in A1. When I change it to the second code to delete instead of hide it is leaving a bunch of rows that the 1st code hides. Both codes have the same search criteria.
Code:
For Each cell In Range("B8:B5000") If cell.Value Range("A1").Value Then cell.EntireRow.Hidden = True
Next cell
Code:
For Each cell In Range("B8:B5000") If cell.Value Range("A1").Value Then cell.EntireRow.Delete
Next cell
View 4 Replies
View Related
Dec 12, 2012
If the user selects French (radio button selection), I want to swap out the existing English text for French and vice versa. One large text box with several paragraphs. Can Excel do this?
View 2 Replies
View Related
Jul 7, 2013
I am trying to take two random Mouse click selections and swap a set of ranges associated with the cells that are selected. For example if the user clicks on A1 it will resize(3,22) and store the selection as a variable to be swapped with another selection. Here is what I have so far but I keep getting a object required error on rngEmp1.
VB:
Sub SwapGroup()
If Selection.Cells.Count < 8 Then
MsgBox "Please Select two Groups to swap. Press and hold 'Ctrl' in between your selections", , "Swap Groups"
[Code] .....
View 4 Replies
View Related
Mar 1, 2014
I need function that swaps text from side to side. Text at the left of "x" should be placed at the right side of the "x" and from right to left side:
6x15 -> 15x6 plaah plaah xsomething -> somethingxplaah plaah How to do this?
View 4 Replies
View Related
Oct 27, 2013
I need to write a macro where i need to copy set of rows from few columns of an excel sheet to another set of columns in same sheet . My excel looks something like this...
Product
F1020
F1023
F1025
F1120
F1123
F1125
[code].....
Now when i filter this table for Product PR01 only rows 1,3,4 will be visible while the other rows remains hidden
I WANT TO COPY ROWS COMING UNDER COLUMNS
F1120
F1123
F1125
TO
F1020
F1023
F1025
when i use the code
Selection.SpecialCells(xlCellTypeVisible).Copy
i get to select ones those are visible but i am not sure how i can PASTE them to rows visible under column f1020 to f1025
Tried this in a frantic effort
Selection.SpecialCells(xlCellTypeVisible).PasteSpecial xlValues
But got an error for " multiple selection"
View 1 Replies
View Related
Jan 22, 2009
I have an excel file that i need to delete some empty rows in the file. it looks like this: I have to delete THE EMPTY ROW above each custom table, and leave everything else as it is.
empty row
custom table
data
data
data
empty row
custom table
data
data
data
data
empty row
custom table
data
data
View 11 Replies
View Related
Nov 10, 2013
For the spreadsheet below I need code to determine what rows to add for the subtotal for each week for each person listed. The rows will vary each time.
Week: WK1
Visit
Date
OMR
Pay Item
UM
Rate
Start
Finish
Time
Subtotal
10/25/13
GA
RG
H
0.00
35
0.00
Totals for WK1: 0 Visit / 2 Admin
[Code] ....
View 1 Replies
View Related
Apr 30, 2014
I am looking for a vba code that will delete rows for me. have data in column E and I need the code to look for any cell that has the word "DELETE" in column E. When it finds the word "DELETE", I need it to delete the entire row. For instance if the first instance of this in cell E41120, then it should delete that entire row and look for the next instance to do the same.
I have seen codes out there to delete rows, but I can't get any of it to work for my situation.
View 7 Replies
View Related
May 24, 2008
I am trying to modify the below code in order for it to:
1) Check the cells in Column A to find any blank cells and zero values. If the macro finds a blank cell or a zero then delete the entire row.
2) Check the cells in Column D for any blank cells and "N/A" (this N/A is text, it is not an excel error). If the macro finds a blank cell or "N/A" then delete the entire row.
Here is the old code
Sub DL()
Dim lastrow As Long, i As Long
With ActiveSheet
On Error Resume Next
.Columns(3).SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0
lastrow = .Cells(Rows.Count, 3).End(xlUp).Row
For i = lastrow To 1 Step -1
If .Range("C" & i).Value = 0 And .Range("D" & i).Value = 0 Then .Rows(i).Delete
If .Range("C" & i).Value = "N/A" Then .Rows(i).Delete
Next i
End With
End Sub
Here is the modified code...
Sub DL()
Dim lastrow As Long, i As Long
With ActiveSheet
On Error Resume Next
.Columns(3).SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0
lastrow = .Cells(Rows.Count, 3).End(xlUp).Row
For i = lastrow To 1 Step -1
If .Range("A" & i).Value = 0 And .Range("A" & i).Value = "" Then .Rows(i).Delete
If .Range("D" & i).Value = "" and .Rang("D" & i).Value ="N/A" Then .Rows(i).Delete
Next i
End With
End Sub
1) Is this the correct and efficient way to accomplish the task?
2) How to i change this in order to select a specific sheet?
View 9 Replies
View Related
Jan 1, 2009
I have data in cells Starting from
B1= Quality, C1= Size, D1= Quantity, E1= Length, F1= Width, G1= Thickness
My data comprises from B2:D2000 ( I am exporting data from SQL Server) so the data is in the horrible conditions , having blanks cells in these three columns . Columns E , F and G are empty.
Can someone help me in cleaning these empty rows in the three columns on the following conditions
delete entire row if column B, C and D contains empty or blank cells or zero
delete entire row if any cells in Column C and D contains text values
delete the entire row if Cells in colums A contains the word Map
the data in the column C is in the following format( Length x Width x Thickness)
C2=78x36x4
C3=78.5x36.5x4.5
C4=7x4x3
C5=72x36x0.5
C6=72x36x19mm
Is it possible to get this data in the following form
E2=78,F2=36,G2=4
E3=78.5,F3=36.5,G3=4.5
E4=7,F4=4,G4=3
E5=72,F5=36,F6=0.5
E6=72,F6=36,G6=19mm
View 9 Replies
View Related
Mar 26, 2009
(excel 2007)
I am using the following piece of code, which I have copied and modified from another workbook in which it worked properly.
Option Explicit
Sub DeleteRows()
'Delete Unneeded Rows
Dim lUsedRangeRows As Long
Dim lRowCounter As Long
With ThisWorkbook.Sheets("Data")
lUsedRangeRows = .UsedRange.Rows.Count
For lRowCounter = lUsedRangeRows To 3 Step -1 'work from the bottom up
If DateValue(.Cells(lRowCounter, 5)) < DateValue(.Range("PayDate")) Then
.Cells(lRowCounter, 5).EntireRow.Delete
End If
Next lRowCounter
End With
End Sub
I receive a "Type Mismatch Error" on the If DateValue line (highlighted red). PayDate is a named range for cell A2 on the same page.
View 9 Replies
View Related
Dec 6, 2012
I got the following code to sum values for columns from this post in the forums. It works perfectly
VB:
With xl.ActiveSheet.Range("A7").CurrentRegion
If .Cells(.Rows.Count, 1).value <> "Total" Then
With .Offset(.Rows.Count).Resize(1)
.Formula = "=SUM(R2C:R[-1]C)"
.Columns(1).value = "Total"
End With
End If
End With
However I would like to do the same for the rows of data in my sheet, with a "Totals" column added on to the first empty column to the right. To provide some background, my worksheet is very similar to a pivot table. So the actual data starts a few columns to the right from A, and it extends to the right for an unkown length. I am using xlToRight to set a variable 'a'.
I like this code because it doesn't Dim any new variables because this will have to be re used about 5 times in the context of a loop and I already have way too many variables going. But if I have to use them it is okay.
I tried modifying the above code with .FormulaR1C1 = "=SUM(RC[-11]:RC[-1])" to no avail.
View 1 Replies
View Related
Jul 10, 2014
automatically hiding empty rows on my table... though the table has been referenced via string of formulas which I added up on my worksheet.. Some of the rows on my table are empty and I tried a VBA code on automatically deleting the rows but then I realized that if that certain 'referenced' string of that cell is not empty anymore, that would cause me much trouble.. so basically I need a code that would automatically hide the rows that displays a result of "" and unhides when it is not empty.
View 14 Replies
View Related
Apr 8, 2014
I need a code to enter 2 blank rows at each change in data in column B with totals entered at the end of columns E-J.
I have attached a sample with a before and after tab.
View 3 Replies
View Related
Jan 25, 2014
I am looking to create a userform to add new rows to a sheet, and continue the formulas in certain columns.
The user starts by entering a number in the text box tbRowAdd. When the user clicks on the button called btAdd it first checks to make sure the number entered is equal to or between 1 and 1500. If this is not the case it should display a message box saying "You must enter a valid number from 1 to 1500 in the tex box."
If the number is valid it should then add that amount of rows below the current active cell in the worksheet ReturnData.
It should then continue the formulas in the A, B, C and F columns. The formulas are as follows:
A: =IFERROR(IF($D6="", "", ROW($A6)-ROWS($A$1:$K$5)),"")
B: =IFERROR(RANK($C6,$C$6:$C$99986, 1),"")
C: =IFERROR(IF(OR(AND(ReturnData!$D6>=Search!$E$1, ReturnData!$D6<=Search!$E$2),OR(Search!$E$1="", Search!$E$2="")), IFERROR(SEARCH(Search!$E$3,$E6,1),"")-(-IFERROR(SEARCH(Search!$E$4,$F6,1),""))-(-IFERROR(SEARCH(Search!$E$5,$G6,1),""))-(-IFERROR(SEARCH(Search!$E$6,$H6,1),""))-(-IFERROR(SEARCH(Search!$E$7,$I6,1),""))+ROW()/100000, ""), "")
F: =IFERROR(VLOOKUP($G6, EquipmentData!$B$3:$C$1048576, 2, FALSE),"")
Each number in bold should match the row number (I dont know if this happens automatically or requires coding).
View 5 Replies
View Related