Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 101
Default Need help - Macro to copy a specific range

Hello everybody,

I have a macro to copy a range of cells (A2:AB100) from sheet1 and
paste it to another file as values.


Set sourceRange = ThisWorkbook.Worksheets("Sheet1").Range("A2:AB100" )


I would like to insert one more code so as it should copy only todays
data;


If B2 = todays date then the range of cells to copy should be (A2:AB2)
If B3 = todays date then the range of cells to copy should be (A3:AB3)
If both B2 and B3 = todays date then the range of cells to copy should
be (A2:AB3)
If all the cells from B2 to B100 = todays date then the range of cells
to copy should be (A2:AB100)


Any help is greatly appreciated.


Thanks & Regards
Dileep Chandran

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default Need help - Macro to copy a specific range

Hi

Dim nrows as long
nrows=Application.Countif(Range("B2:B100"),Date)
Set sourceRange = ThisWorkbook.Worksheets("Sheet1").Range("A2:AB" &
nrows)


--
Regards

Roger Govier


"Dileep Chandran" wrote in message
oups.com...
Hello everybody,

I have a macro to copy a range of cells (A2:AB100) from sheet1 and
paste it to another file as values.


Set sourceRange = ThisWorkbook.Worksheets("Sheet1").Range("A2:AB100" )


I would like to insert one more code so as it should copy only todays
data;


If B2 = todays date then the range of cells to copy should be (A2:AB2)
If B3 = todays date then the range of cells to copy should be (A3:AB3)
If both B2 and B3 = todays date then the range of cells to copy should
be (A2:AB3)
If all the cells from B2 to B100 = todays date then the range of cells
to copy should be (A2:AB100)


Any help is greatly appreciated.


Thanks & Regards
Dileep Chandran



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 101
Default Need help - Macro to copy a specific range


Thanks Roger, Instead of "Date", is it possible to give "Today()" ?

-Dileep

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,726
Default Need help - Macro to copy a specific range

Date is VBA speak for TODAY()

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"Dileep Chandran" wrote in message
ups.com...

Thanks Roger, Instead of "Date", is it possible to give "Today()" ?

-Dileep



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 101
Default Need help - Macro to copy a specific range

Thanks Bob!!!



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 101
Default Need help - Macro to copy a specific range

Ok, Thats good. Before copying this specified range is it possible to
unhide all rows and columns in Sheet1?

-Dileep

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default Need help - Macro to copy a specific range

Hi Dileep

Cells.Select
Selection.EntireRow.Hidden = False
Selection.EntireColumn.Hidden = False

--
Regards

Roger Govier


"Dileep Chandran" wrote in message
oups.com...
Ok, Thats good. Before copying this specified range is it possible to
unhide all rows and columns in Sheet1?

-Dileep



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Need help - Macro to copy a specific range

or

Sub uh()
Rows.Hidden = False
Columns.Hidden = False
End Sub


--
Don Guillett
SalesAid Software

"Roger Govier" wrote in message
...
Hi Dileep

Cells.Select
Selection.EntireRow.Hidden = False
Selection.EntireColumn.Hidden = False

--
Regards

Roger Govier


"Dileep Chandran" wrote in message
oups.com...
Ok, Thats good. Before copying this specified range is it possible to
unhide all rows and columns in Sheet1?

-Dileep





  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 101
Default Need help - Macro to copy a specific range

This is good. But I want to unhide all rows and columns in Sheet1 while
I am running the macro from Sheet2

Is it possible?

-Dileep

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 101
Default Need help - Macro to copy a specific range

I have inserted: Sheets("Sheet1").Select to the code. Its now working
fine.

Thank you all. Your timely help is really appreciated.

Regards
Dileep Chandran

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
Count Specific word in specific range [email protected] Excel Worksheet Functions 2 May 16th 06 10:30 AM
Count If Specific word in specific range [email protected] Excel Discussion (Misc queries) 2 May 16th 06 10:14 AM
MACRO TO COPY TO A RANGE asuncionw Excel Discussion (Misc queries) 3 February 9th 06 04:39 PM
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


All times are GMT +1. The time now is 10:13 AM.

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

About Us

"It's about Microsoft Excel"