PC Review


Reply
Thread Tools Rate Thread

How to copy one column values to another column based on conditionthat row2 contain todays date

 
 
sanju
Guest
Posts: n/a
 
      13th Apr 2010
Hi

I am struck up in my code and getting error. It is pretty simple one.

I have to copy values from column 32 row 3 onwards i.e. cell (x,32) to
column C row 3 onwards i.e. cell(x, C).
Column C is column whose row 2 contain today's date.

I hope I am clear. To simplify this I am taking an example:-

If cell (2,45) contain todays date then copy all cells(3 onwards, 32)
to cells(3onwards,45).
If cell(2,50) contain todays date then copy all cells(3onwards,32) to
cells(3onwards,45).
If cell(2,100) contain todays date then copy all cells(3onwards,32) to
cells(3onwards,100)
If cell(2,200) contain todays date then copy all cells(3onwards,32) to
cells(3onwards,200)

If anything is unclear, please let me know so that I can send you the
file.

Regards
San

 
Reply With Quote
 
 
 
 
Jef Gorbach
Guest
Posts: n/a
 
      13th Apr 2010
On Apr 13, 1:37*am, sanju <sun...@gmail.com> wrote:
> Hi
>
> I am struck up in my code and getting error. It is pretty simple one.
>
> I have to copy values from column 32 row 3 onwards i.e. cell (x,32) to
> column C row 3 onwards i.e. cell(x, C).
> Column C is column whose row 2 contain today's date.
>
> I hope I am clear. To simplify this I am taking an example:-
>
> If cell (2,45) contain todays date then copy all cells(3 onwards, 32)
> to cells(3onwards,45).
> If cell(2,50) contain todays date then copy all cells(3onwards,32) to
> cells(3onwards,45).
> If cell(2,100) contain todays date then copy all cells(3onwards,32) to
> cells(3onwards,100)
> If cell(2,200) contain todays date then copy all cells(3onwards,32) to
> cells(3onwards,200)
>
> If anything is unclear, please let me know so that I can send you the
> file.
>
> Regards
> San



Here's a starting point for you.
You didn't say where the results are being copied to, so i sent them
to the second sheet tab.
It works when the Today variable is a fixed number (ie the date's
serial number, 40281 for 4-13-2010 for instance) however isn't finding
anything when i assign it to the system date via Now.


Sub FilterCopy()
Dim CopyRange As Range
Dim today
today = Now
Set CopyRange = Range("A1:k100")
CopyRange.AutoFilter Field:=3, Criteria1:=today
CopyRange.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("Sheet2").Range("A2")
Application.CutCopyMode = False
End Sub

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      13th Apr 2010
I am not sure I understood everything, but give this a try and post back
with results.

Sub vert()
Dim lc As Long, sh As Worksheet, rng As Range
Dim lr As Long, cRng As Range
Set sh = ActiveSheet
lc = sh.Cells(2, Columns.Count).End(xlToLeft).Column
Set rng = sh.Range("C2", sh.Cells(2, lc))
lr = sh.Cells(Rows.Count, 32).End(xlUp).Row
Set cRng = sh.Range(sh.Cells(3, 32), Cells(lr, 32))
For Each c In rng
If c = Date Then
cRng.Copy c.Offset(1, 0)
End If
Next
End Sub





"sanju" <(E-Mail Removed)> wrote in message
news:b2e79c4a-832a-4f23-804c-(E-Mail Removed)...
> Hi
>
> I am struck up in my code and getting error. It is pretty simple one.
>
> I have to copy values from column 32 row 3 onwards i.e. cell (x,32) to
> column C row 3 onwards i.e. cell(x, C).
> Column C is column whose row 2 contain today's date.
>
> I hope I am clear. To simplify this I am taking an example:-
>
> If cell (2,45) contain todays date then copy all cells(3 onwards, 32)
> to cells(3onwards,45).
> If cell(2,50) contain todays date then copy all cells(3onwards,32) to
> cells(3onwards,45).
> If cell(2,100) contain todays date then copy all cells(3onwards,32) to
> cells(3onwards,100)
> If cell(2,200) contain todays date then copy all cells(3onwards,32) to
> cells(3onwards,200)
>
> If anything is unclear, please let me know so that I can send you the
> file.
>
> Regards
> San
>



 
Reply With Quote
 
sanju
Guest
Posts: n/a
 
      15th Apr 2010
On Apr 13, 7:26*pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:
> I am not sure I understood everything, but give this a try and post back
> with results.
>
> Sub vert()
> * *Dim lc As Long, sh As Worksheet, rng As Range
> * *Dim lr As Long, cRng As Range
> * *Set sh = ActiveSheet
> * *lc = sh.Cells(2, Columns.Count).End(xlToLeft).Column
> * *Set rng = sh.Range("C2", sh.Cells(2, lc))
> * *lr = sh.Cells(Rows.Count, 32).End(xlUp).Row
> * *Set cRng = sh.Range(sh.Cells(3, 32), Cells(lr, 32))
> * *For Each c In rng
> * * * If c = Date Then
> * * * * *cRng.Copyc.Offset(1, 0)
> * * * End If
> * *Next
> End Sub
>
> "sanju" <sun...@gmail.com> wrote in message
>
> news:b2e79c4a-832a-4f23-804c-(E-Mail Removed)...
>
>
>
> > Hi

>
> > I am struck up in my code and getting error. It is pretty simple one.

>
> > I have tocopyvalues from column 32 row 3 onwards i.e. cell (x,32) to
> > column C row 3 onwards i.e. cell(x, C).
> > Column C is column whose row 2 contain today's date.

>
> > I hope I am clear. To simplify this I am taking an example:-

>
> > If cell (2,45) contain todays date thencopyall cells(3 onwards, 32)
> > to cells(3onwards,45).
> > If cell(2,50) contain todays date thencopyall cells(3onwards,32) to
> > cells(3onwards,45).
> > If cell(2,100) contain todays date thencopyall cells(3onwards,32) to
> > cells(3onwards,100)
> > If cell(2,200) contain todays date thencopyall cells(3onwards,32) to
> > cells(3onwards,200)

>
> > If anything is unclear, please let me know so that I can send you the
> > file.

>
> > Regards
> > San- Hide quoted text -

>
> - Show quoted text -


Hi it is fine . Working all right in active sheet. How can I make it
work for all the sheets if workbook.

Regards
sanjay
 
Reply With Quote
 
sanju
Guest
Posts: n/a
 
      16th Apr 2010


Thanks Whiz,
Please let me know there are any conditions for this. As in the same
worksheet, it was working for some column only. I could not figure out
why this is not working for other columns.

Regards
sanajy
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Unique Values in 1 Column based on Date Range in another Column Brian Microsoft Excel Worksheet Functions 28 17th May 2009 02:58 PM
Count Unique Values in 1 Column based on Date Range in another Column Brian Microsoft Excel Worksheet Functions 0 16th May 2009 04:44 PM
Copy Color Formats Based On Column Date Values Naji Microsoft Excel Misc 0 11th Jan 2006 09:06 PM
macro to transpose cells in Column B based on unique values in Column A Aaron J. Microsoft Excel Programming 3 8th Oct 2004 02:29 PM
Calculating values to column D with formula based on values column A spolk Microsoft Excel Programming 1 30th Apr 2004 06:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 AM.