Add sheet and change cell reference

Maheshp

Board Regular
Joined
Jul 29, 2009
Messages
186
i have sheet1 which is link with other workbooks i want, when i add new sheet the cell address will increase by one
if cell address is A2 then when i add new sheet(copy of sheet1) in same cell it will reflect A3
i will appreciate any help on this, i need vb if possible provide formula also

sheet1 formula's


Cell("B6").value ='C:\Users\Desktop\F.Y 2010-11\[Book1.xls]Main'!$A$2Cell("B7").value='C:\Users\Desktop\F.Y 2010-11\[Book2.xls]Main'!$A$2Cell("B10").value='C:\Users\Desktop\F.Y 2010-11\[Book3.xls]Main'!$B$10Sheet 2Cell("B6").value ='C:\Users\Desktop\F.Y 2010-11\[Book1.xls]Main'!$A$3Cell("B7").value='C:\Users\Desktop\F.Y 2010-11\[Book2.xls]Main'!$A$3Cell("B10").value='C:\Users\Desktop\F.Y 2010-11\[Book3.xls]Main'!$B$11</PRE>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi
i find the solution :), someone else find this helpful
Code:
Sub test()
Dim i, x, a As Long
Dim path1 As String
path1 = "=+'C:\Users\Desktop\F.Y 2010-11\[Book1.xls]Main'!"
With ActiveSheet
d = DateValue("01-" & .Name)
x = 3
a = x + 1
Cells(6, 3).Formula = path1 & "C" & x
For i = a To 6
ActiveSheet.Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(DateAdd("m", i, d), "mmm-yy")
Cells(6, 3).Formula = path1 & "C" & i
Next i
End With
End Sub
 
Upvote 0
Glad you found a solution. For info it should be


Code:
Dim i As Long, x As Long, a As Long
 
Upvote 0
Thank you so much for your reply Sir,
Any reason behind declaring variable as
Code:
Dim i As Long, x As Long, a As Long
instead of
Code:
Dim i, x, a As Long
in both the cases i,x & a will be as long, what is difference between both statements ?
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top