Processing
 

Using cells value as part of VBA code?

25/08/2016 06:31#1

bluehawk

Member

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

Hi everyone I am an extreme newbie with excel VBA and really could use some help.

So I have some working code, and in that code there are some sheet names that need to be updated periodically. I would prefer not to re-enter the new sheet name into the code every time I need to update the sheet names. Is there a way the code can pull the sheet name from a cell. That way I can just type the sheet name once into a cell and then the all the code will reference that.

So instead of typing in the sheet name "Hello" for example, it would just reference the cell "F20" to get that sheet name.

It's late and I hope this makes sense. Thank you.

25/08/2016 06:43Top#2

TobiasR.

Member

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

Should be

ActiveSheet.Cells(20, 6).Value 
25/08/2016 06:44Top#3

KyloRen

Member

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

Yes you can,

ActiveSheet.Name = Range("F20") 
25/08/2016 07:25Top#4

asipoy

Member

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

You can pass the cell value containing Sheet name to a variable and then use that Variable to select the sheet. For multiple sheets you can use the loop to select and take action.

Sub test()    shtName = Range("A1")    Sheets(shtName).Select End Sub 
Similar articles

Excel More conditions in one formula?

5 months ago - Reply: 2 - Views: 172

Get Workbook reference from Open File dialog

5 months ago - Reply: 2 - Views: 130

Add Calculated Field To Pivot Table

6 months ago - Reply: 0 - Views: 7

Nested IF Functions in Excel not working

6 months ago - Reply: 3 - Views: 164

Formulating Date in Excel 2013

6 months ago - Reply: 2 - Views: 88

VB6 extracts in Excel 2013

6 months ago - Reply: 2 - Views: 153

Excel 2013 : Pull Matching Data from Column

6 months ago - Reply: 1 - Views: 23

excel search and copy in/from another file

6 months ago - Reply: 0 - Views: 1

Buggy PivotTable.ColumnRange

6 months ago - Reply: 0 - Views: 6

Excel static conditional formatting area

6 months ago - Reply: 0 - Views: 8

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re