user2282522 February 2016

VBA code to subtract first two digits from a range

i have a code to copy data from 31 excel file and merge it to one file, i did the job i only have one issue; im copying one cell from every source file and past it in all its records in the destination file (every file from the 31 have a different value so im copying this value and paste it beside its records) the issue is i need to substract this value to only copy the first two digits but my code copy anything in this cell "G2" and past it in column A.. can you please help me as im not a vba expert i only googeled for this code.

    Set Sourcedate = WorkBk.Worksheets(1).Cells.Range("G2")
    Set Distdate = SummarySheet.Range("A" & NRow)
    Set Distdate = Distdate.Resize(SourceRange.Rows.Count - 1)

Answers


Sixthsense February 2016

'Change Declaration of Sourcedate to String if it is in Range
Dim Sourcedate As String

Sourcedate = Left(WorkBk.Worksheets(1).Cells.Range("G2"), 2)

Post Status

Asked in February 2016
Viewed 3,260 times
Voted 11
Answered 1 times

Search




Leave an answer