Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default moving columns

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default moving columns


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving columns with formulas gives #REF! Miss Kitty[_2_] Excel Worksheet Functions 0 August 20th 08 03:12 PM
Moving Columns egrave Excel Discussion (Misc queries) 1 July 6th 08 11:09 PM
Moving columns about green biro Excel Programming 1 October 30th 07 10:54 PM
Moving Columns only hyyfte[_16_] Excel Programming 0 September 22nd 04 04:03 PM
Moving Columns gminor7 Excel Programming 2 September 12th 03 03:27 PM


All times are GMT +1. The time now is 02:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"