Hi,
I have a vba code (see below) which creates a tab worksheet and is named as per the text entered in cell 'G2'; and enters the same name into another sheet which is called 'OPERATION'. So the vba works well, now the problem I have is using indirect formula to recall the tab name in a cell in wk 'OPERATION'
=SUMIF(INDIRECT(A3&"!I&I"),$K$1,INDIRECT(A3&"!K:K")
Cell A3= name which is the same as per the tab worksheet that was created by the vba
The formula works well when there is no spaces inbetween the words, but the formula doesn't work when there are spaces. Any advise on this?
Sub Copyrenameworksheet()
Dim ws As Worksheet
Set wh = Worksheets(ActiveSheet.Name)
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
If wh.Range("G2").Value <> "" Then
ActiveSheet.Name = wh.Range("G2").Value
End If
'wh.Activate
Dim src As Worksheet
Dim dst As Worksheet
Dim rw As Long
Application.ScreenUpdating = False
Set src = Sheets("FORM")
Set dst = Sheets("OPERATION")
rw = dst.Cells(Rows.Count, "A").End(xlUp).Row + 1
dst.Cells(rw, "A") = src.Range("G2")
dst.Cells(rw, "B") = src.Range("G3")
Application.ScreenUpdating = True
Range("G2:G3").ClearContents
Range("K6:K67").ClearContents
End Sub
Kind Regards,
Dan
I have a vba code (see below) which creates a tab worksheet and is named as per the text entered in cell 'G2'; and enters the same name into another sheet which is called 'OPERATION'. So the vba works well, now the problem I have is using indirect formula to recall the tab name in a cell in wk 'OPERATION'
=SUMIF(INDIRECT(A3&"!I&I"),$K$1,INDIRECT(A3&"!K:K")
Cell A3= name which is the same as per the tab worksheet that was created by the vba
The formula works well when there is no spaces inbetween the words, but the formula doesn't work when there are spaces. Any advise on this?
Sub Copyrenameworksheet()
Dim ws As Worksheet
Set wh = Worksheets(ActiveSheet.Name)
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
If wh.Range("G2").Value <> "" Then
ActiveSheet.Name = wh.Range("G2").Value
End If
'wh.Activate
Dim src As Worksheet
Dim dst As Worksheet
Dim rw As Long
Application.ScreenUpdating = False
Set src = Sheets("FORM")
Set dst = Sheets("OPERATION")
rw = dst.Cells(Rows.Count, "A").End(xlUp).Row + 1
dst.Cells(rw, "A") = src.Range("G2")
dst.Cells(rw, "B") = src.Range("G3")
Application.ScreenUpdating = True
Range("G2:G3").ClearContents
Range("K6:K67").ClearContents
End Sub
Kind Regards,
Dan