Getting last value in Excel workb and copy

Closed
nvanzyl24 - Oct 25, 2009 at 03:57 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Oct 26, 2009 at 09:19 PM
Hello, wondering if some1 can help me.

I have 2 worksheets CertNo.xls and UncertB.xls.
In UncertB.xls i have a button. When i click this button i need to get info from the CertNo.xls worksheet.
In this worksheet i have a column A containing numbers which represent a certificate no. the customer column B and the date column C. I need to find the last cert no used and pass it to the UncertB sheet. In this sheet the macro must add a 1 to the number it got to create a new certificate no. and this value goes to cell D5 in UncertB workbook.

Is this possible?
Related:

3 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 25, 2009 at 08:54 PM
copy paste this macro in a standard module . the macro is named "test"
assign this macro to the button

Sub test()
Dim r As Range, x
With Worksheets("certno")
Set r = .Range("A1").End(xlDown)
x = r.Value
x = x & 1
With Worksheets("uncertb")
.Range("D5") = x
End With
End With
End Sub
1
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 25, 2009 at 08:56 PM
Sorry I forgot to add
worksheets names need not have ".xls". only workbooks need that suffix
0
Hey Thanks for the reply.
What would i have to do if the 2 sheets where in 2 differnt workbooks. e.g. UncertB.xls and CertNo.xls and i need to get the info from CertNo and add a 1 to it and paste it in UncertB.xls?

Hope u could help me.
Thanks
0
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 26, 2009 at 09:19 PM
keep both the saved workbooks open and try this macro( I have not tested)

Sub test()
Dim r As Range, x
With Workbooks("certno.xls").Worksheets("certno")
Set r = .Range("A1").End(xlDown)
x = r.Value
x = x & 1
With Workbooks("uncertb.xls").Worksheets("uncertb")
.Range("D5") = x
End With
End With
End Sub
0