Hi All,
Need help to find the last row in column and paste the H2 formula up to last column till the data is present in last row. Used below code but not getting success. Also code will automatically add column name Mid value in H column. Example if cell H2 contains a formula of mid(G2,20,2) will give P2 value. And that formula should copy till last used row of that column and paste the formula.
I am also adding 3 columns through code named Mid Value, Time Cal and Time in Minutes
Please change the destination of source file according to your convenient.
Moderator: This is third version of same thread.
Do not open always new Your own thread, use Your just done thread.
>>> use code - tags <<<
Thanks & Regards,
Amit
Need help to find the last row in column and paste the H2 formula up to last column till the data is present in last row. Used below code but not getting success. Also code will automatically add column name Mid value in H column. Example if cell H2 contains a formula of mid(G2,20,2) will give P2 value. And that formula should copy till last used row of that column and paste the formula.
I am also adding 3 columns through code named Mid Value, Time Cal and Time in Minutes
Please change the destination of source file according to your convenient.
Moderator: This is third version of same thread.
Do not open always new Your own thread, use Your just done thread.
>>> use code - tags <<<
Code:
Option Explicit
Sub Timecalculation()
Dim wb As Workbook
Dim wks As Worksheet
Dim objList As ListObject
Dim LastRow As Long
Dim sht As Worksheet
Set wb = Workbooks.Open("C:\Users\Desktop\SourceData.xlsx")
wb.Sheets("Data").Activate
For Each wks In ActiveWorkbook.Worksheets
For Each objList In wks.ListObjects
objList.Unlist
Next objList
Next wks
Range("H1").Select
'adding column for Mid Value
Set sht = ActiveSheet
Columns("H:H").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("H1").Value = "Mid Value"
ActiveSheet.Range("H2").Select
ActiveCell.FormulaR1C1 = "=Mid(RC[-1],20,2)"
Selection.Copy
Range("H3").Select
LastRow = Range("H" & Rows.Count).End(xlUp).Row
Range("H2:H" & LastRow).Formula = "=&H2"
Range("I1").Select
ActiveSheet.AutoFilterMode = False
'Adding column for time calculate
Columns("I:I").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Value = "Time Cal"
Range("J1").Select
'Adding column for time in Minutes
Columns("J:J").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("J1").Value = "Time In Minutes"
Application.DisplayAlerts = False
End Sub
Thanks & Regards,
Amit
Attachments
Last edited by a moderator: