Macro help

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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:
 
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
 
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

Macro Loop 1
Macro Flexability 7
Profress Indicator 2
Macros in excel 2000 12
I need a simple loop with a 4+ row added in. 5
Macro - very slow run in 2003 3
Hard reference in a macro 1
Modify range in VBA 9

Back
Top