Macro help

G

Guest

Sir,

I am getting daily an excel file with data which varies every day. I have
recorded a macro to check the data which is given below:
Sub checktime()
Range("D1").Select
Selection.EntireColumn.Insert
Range("D1").Select
ActiveCell.FormulaR1C1 = "TTime"
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=AND(RC[-1]>=--LEFT(RC[8],5),RC[-1]<=--RIGHT(RC[8],5))"
Range("D2").Select
Selection.Copy
Range("D3:D721").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("D1").Select
End Sub

my problem is that, I want to paste the copied cell("D2") down till the row
in which there is data in column C.
please provide a modification in the code to accommodate the the above.

thanks
 
G

Guest

Try this version:
LastRowInC = Range("C" & Rows.Count).End(xlUp).Row
Range("D3:D" & LastRowInC).Select


Sub checktime()
Range("D1").Select
Selection.EntireColumn.Insert
Range("D1").Select
ActiveCell.FormulaR1C1 = "TTime"
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=AND(RC[-1]>=--LEFT(RC[8],5),RC[-1]<=--RIGHT(RC[8],5))"

LastRowInC = Range("C" & Rows.Count).End(xlUp).Row

Range("D2").Select
Selection.Copy

Range("D3:D" & LastRowInC).Select

ActiveSheet.Paste
Application.CutCopyMode = False
Range("D1").Select
End Sub

Regards,
Stefi


„shaji†ezt írta:
 
D

Don Guillett

try this
sub copydo()
lr=cells(rows.count,"c").end(xlup).row
range("d1")="TTime"
Range("D2").FormulaR1C1 = _
"=AND(RC[-1]>=--LEFT(RC[8],5),RC[-1]<=--RIGHT(RC[8],5))"
Range("D2").copy Range("D3:D" & lr)
end sub
 
G

Guest

it is working great.

thanks


Stefi said:
Try this version:
LastRowInC = Range("C" & Rows.Count).End(xlUp).Row
Range("D3:D" & LastRowInC).Select


Sub checktime()
Range("D1").Select
Selection.EntireColumn.Insert
Range("D1").Select
ActiveCell.FormulaR1C1 = "TTime"
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=AND(RC[-1]>=--LEFT(RC[8],5),RC[-1]<=--RIGHT(RC[8],5))"

LastRowInC = Range("C" & Rows.Count).End(xlUp).Row

Range("D2").Select
Selection.Copy

Range("D3:D" & LastRowInC).Select

ActiveSheet.Paste
Application.CutCopyMode = False
Range("D1").Select
End Sub

Regards,
Stefi


„shaji†ezt írta:
Sir,

I am getting daily an excel file with data which varies every day. I have
recorded a macro to check the data which is given below:
Sub checktime()
Range("D1").Select
Selection.EntireColumn.Insert
Range("D1").Select
ActiveCell.FormulaR1C1 = "TTime"
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=AND(RC[-1]>=--LEFT(RC[8],5),RC[-1]<=--RIGHT(RC[8],5))"
Range("D2").Select
Selection.Copy
Range("D3:D721").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("D1").Select
End Sub

my problem is that, I want to paste the copied cell("D2") down till the row
in which there is data in column C.
please provide a modification in the code to accommodate the the above.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top