Home

Using cell value to link to a different worksheet

%3CLINGO-SUB%20id%3D%22lingo-sub-648680%22%20slang%3D%22en-US%22%3EUsing%20cell%20value%20to%20link%20to%20a%20different%20worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-648680%22%20slang%3D%22en-US%22%3E%3CP%3EFairly%20straightforward%20question%2C%20hopefully.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20anyone%20know%20how%20to%20use%20the%20value%20of%20a%20cell%20to%20link%20to%20another%20worksheet%20in%20the%20same%20workbook%2C%20so%20if%20the%20value%20of%20the%20cell%20changes%2C%20the%20formula%20using%20it%20links%20to%20a%20different%20worksheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESay%20if%20cell%20A1%20on%20Sheet1%20contained%20the%20text%20%3CSTRONG%3ESheet2%3C%2FSTRONG%3E%20and%20other%20formulas%20referenced%20A1%20to%20link%20to%20Sheet2%2C%20but%20if%20the%20value%20of%20A1%20was%20changed%20to%20%3CSTRONG%3ESheet6%3C%2FSTRONG%3E%20then%20the%20formulas%20would%20look%20there%20instead.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20that%20makes%20sense%2C%20but%20if%20it%20doesn't%2C%20then%20I'm%20sorry!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3EPhil%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-648680%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-648707%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20cell%20value%20to%20link%20to%20a%20different%20worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-648707%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F349066%22%20target%3D%22_blank%22%3E%40Phil_Turton%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Phil%2C%3C%2FP%3E%3CP%3Eyou%20can%20do%20this%20with%20worksheet_change%20event.%20See%20attached%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%3CBR%20%2F%3E%3CBR%20%2F%3EWith%20ActiveSheet%3CBR%20%2F%3E%3CBR%20%2F%3E.Range(%22A1%22).Hyperlinks.Delete%3CBR%20%2F%3E%3CBR%20%2F%3E.Hyperlinks.Add%20Anchor%3A%3D.Range(%22A1%22)%2C%20Address%3A%3D%22%22%2C%20SubAddress%3A%3D%20_%3CBR%20%2F%3E.Range(%22A1%22).Value%20%26amp%3B%20%22!A1%22%2C%20TextToDisplay%3A%3D.Range(%22A1%22).Value%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%26nbsp%3B%3C%2FP%3E%3CP%3EBernd%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.vba-Tanker.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ewww.vba-Tanker.com%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-648889%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20cell%20value%20to%20link%20to%20a%20different%20worksheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-648889%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F347933%22%20target%3D%22_blank%22%3E%40Berndvbatanker%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Bernd%2C%3C%2FP%3E%3CP%3EThanks%20for%20your%20help%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EPhil%3C%2FP%3E%3C%2FLINGO-BODY%3E
Phil_Turton
New Contributor

Fairly straightforward question, hopefully.

 

Does anyone know how to use the value of a cell to link to another worksheet in the same workbook, so if the value of the cell changes, the formula using it links to a different worksheet.

 

Say if cell A1 on Sheet1 contained the text Sheet2 and other formulas referenced A1 to link to Sheet2, but if the value of A1 was changed to Sheet6 then the formulas would look there instead.

 

I hope that makes sense, but if it doesn't, then I'm sorry!

 

Cheers

Phil

 

 

 

2 Replies

@Phil_Turton 

Hi Phil,

you can do this with worksheet_change event. See attached file.

 

Private Sub Worksheet_Change(ByVal Target As Range)

With ActiveSheet

.Range("A1").Hyperlinks.Delete

.Hyperlinks.Add Anchor:=.Range("A1"), Address:="", SubAddress:= _
.Range("A1").Value & "!A1", TextToDisplay:=.Range("A1").Value

End With

End Sub

 

Regards 

Bernd

www.vba-Tanker.com

@Berndvbatanker 

 

Hi Bernd,

Thanks for your help

Regards

Phil

Related Conversations