Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello, there was a previously posted solution that worked great for moving
the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think this is what you want:
Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell End With End Sub Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Once the searched item is found, then data in location relative to the found item cell can be cut, copied or otherwise manipulated to anywhere in the workbook or other workbooks if need be. The only condition is that if it is to be a repetitive operation, there must be a consistent criteria that allows the data to be found and to be located elsewhere. i.e. paste in next empty cell in a row or next empty cell in a column, etc. Actually, data can be moved from one place to any other place, but it is not practical to write code for random movement or erratic movement. "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Forgot to turn of the copy mode.
Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell Application.CutCopyMode = False End With End Sub "JLGWhiz" wrote in message ... I think this is what you want: Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell End With End Sub Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Once the searched item is found, then data in location relative to the found item cell can be cut, copied or otherwise manipulated to anywhere in the workbook or other workbooks if need be. The only condition is that if it is to be a repetitive operation, there must be a consistent criteria that allows the data to be found and to be located elsewhere. i.e. paste in next empty cell in a row or next empty cell in a column, etc. Actually, data can be moved from one place to any other place, but it is not practical to write code for random movement or erratic movement. "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the reply, I'll try it when I get back to work on Monday. My issue
is that I have thousands of rows of data that I have to compare and move in this manner, was just hoping that I could automate the process instead of cutting and pasting all these cells. "JLGWhiz" wrote: Forgot to turn of the copy mode. Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell Application.CutCopyMode = False End With End Sub "JLGWhiz" wrote in message ... I think this is what you want: Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell End With End Sub Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Once the searched item is found, then data in location relative to the found item cell can be cut, copied or otherwise manipulated to anywhere in the workbook or other workbooks if need be. The only condition is that if it is to be a repetitive operation, there must be a consistent criteria that allows the data to be found and to be located elsewhere. i.e. paste in next empty cell in a row or next empty cell in a column, etc. Actually, data can be moved from one place to any other place, but it is not practical to write code for random movement or erratic movement. "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you can describe the database layout (at least the portion you want to
work with) in terms of columns and rows, header rows, etc. And describe what you do manually that you want to convert to automation, then someone who monitors this group will try to help you. The code that I gave you copies the data from cells in columns G and H to Columns D and E of the same row where a match is found. It leaves the original data intact. If you want to remove the data from the copied cells, simply change the word "Copy" in the code to "Cut" and it will leave the cells blank in column G and H as it pastes the data to D and E. "Dino" wrote in message ... Thanks for the reply, I'll try it when I get back to work on Monday. My issue is that I have thousands of rows of data that I have to compare and move in this manner, was just hoping that I could automate the process instead of cutting and pasting all these cells. "JLGWhiz" wrote: Forgot to turn of the copy mode. Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell Application.CutCopyMode = False End With End Sub "JLGWhiz" wrote in message ... I think this is what you want: Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell End With End Sub Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Once the searched item is found, then data in location relative to the found item cell can be cut, copied or otherwise manipulated to anywhere in the workbook or other workbooks if need be. The only condition is that if it is to be a repetitive operation, there must be a consistent criteria that allows the data to be found and to be located elsewhere. i.e. paste in next empty cell in a row or next empty cell in a column, etc. Actually, data can be moved from one place to any other place, but it is not practical to write code for random movement or erratic movement. "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. The program gave me an error when I ran it. "Run-time error 424.
Object required". Debug mode highlighted the code in the If-End If loop. "JLGWhiz" wrote: If you can describe the database layout (at least the portion you want to work with) in terms of columns and rows, header rows, etc. And describe what you do manually that you want to convert to automation, then someone who monitors this group will try to help you. The code that I gave you copies the data from cells in columns G and H to Columns D and E of the same row where a match is found. It leaves the original data intact. If you want to remove the data from the copied cells, simply change the word "Copy" in the code to "Cut" and it will leave the cells blank in column G and H as it pastes the data to D and E. "Dino" wrote in message ... Thanks for the reply, I'll try it when I get back to work on Monday. My issue is that I have thousands of rows of data that I have to compare and move in this manner, was just hoping that I could automate the process instead of cutting and pasting all these cells. "JLGWhiz" wrote: Forgot to turn of the copy mode. Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell Application.CutCopyMode = False End With End Sub "JLGWhiz" wrote in message ... I think this is what you want: Option Explicit Sub matchCopy() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = myCell.Value Then .Range("G" & myCell.Row & ":H" & myCell.Row).Copy _ .Range("D" & myCell.Row) End If Next myCell End With End Sub Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Once the searched item is found, then data in location relative to the found item cell can be cut, copied or otherwise manipulated to anywhere in the workbook or other workbooks if need be. The only condition is that if it is to be a repetitive operation, there must be a consistent criteria that allows the data to be found and to be located elsewhere. i.e. paste in next empty cell in a row or next empty cell in a column, etc. Actually, data can be moved from one place to any other place, but it is not practical to write code for random movement or erratic movement. "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Disregard. I tested the FIRST CODE. not the question. Offer to look still
stands. Be sure to give before/after examples -- Don Guillett Microsoft MVP Excel SalesAid Software "Don Guillett" wrote in message ... Although I would have done it differently, I tested your code and it worked, as written. If desired, send your file to my address below along with this msg and a clear explanation of what you want and before/after examples. -- Don Guillett Microsoft MVP Excel SalesAid Software "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() OK thanks. When I get back to work I will send you the example. "Don Guillett" wrote: Disregard. I tested the FIRST CODE. not the question. Offer to look still stands. Be sure to give before/after examples -- Don Guillett Microsoft MVP Excel SalesAid Software "Don Guillett" wrote in message ... Although I would have done it differently, I tested your code and it worked, as written. If desired, send your file to my address below along with this msg and a clear explanation of what you want and before/after examples. -- Don Guillett Microsoft MVP Excel SalesAid Software "Dino" wrote in message ... Hello, there was a previously posted solution that worked great for moving the value of one column to another column if certain criteria were met. The code below analyzes column G, and if the cell in the same row in column C is blank, then the value from column G is entered into that cell in column C. Option Explicit Sub Fillblanks() Dim myRng As Range Dim myCell As Range With Activesheet Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp)) For Each myCell In myRng.Cells If .Cells(myCell.Row, "C").Value = "" Then .Cells(myCell.Row, "C").Value = myCell.Value myCell.Value = "" End If Next myCell End With End Sub The result that I need is this: Analyze column G and C the same way, and if the two values are equal to each other, then move the values from column G and H ( I have two columns that are associated with each other) to columns D and E. Would it also be possible to analyze columns C and G, and move the values from G and H to wherever the matching C values are, regardless if they are in the same row or not? Thanks. Dino |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Moving columns with formulas gives #REF! | Excel Worksheet Functions | |||
Moving Columns | Excel Discussion (Misc queries) | |||
Moving columns about | Excel Programming | |||
Moving Columns only | Excel Programming | |||
Moving Columns | Excel Programming |