Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I know almost nothing about visual basic, and my supervisor asked me to add
some things into the code of a spreadsheet. I know what the code is supposed to do, but I honestly don't know if I'm doing it right. Can someone tell me what exactly this is doing?? Sub data() Application.ScreenUpdating = False For Each sht In ActiveWorkbook.Sheets sht.Activate ActiveSheet.unprotect Next Worksheets("Sheet").Visible = True Worksheets("Data").Visible = True Worksheets("Data").Activate Columns("A:B").Hidden = False region = Worksheets("Sheet").Range("Region").Value Cells(3, 3).Select cellcount = Range(Selection, Selection.End(xlDown)).Count umis = 0 umiu = 0 umip = 0 mcpls = 0 mcplu = 0 mcplp = 0 gvfpls = 0 gvfplu = 0 gvfplp = 0 mshs = 0 mshu = 0 mshp = 0 bdchs = 0 bdchu = 0 bdchp = 0 These letter groups represent product lines that are being pulled from one sheet and grouped together and placed in another sheet. I have to add another group, but can I just add it into the code because how will excel know what it is referencing too? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sub data()
'hide the screen flicker so you're not irritated. Application.ScreenUpdating = False 'unprotect all the sheets in the activeworkbook For Each sht In ActiveWorkbook.Sheets sht.Activate ActiveSheet.unprotect Next 'make a worksheet named Sheet visible (maybe it was hidden??) Worksheets("Sheet").Visible = True 'make a worksheet named Data visible (maybe it was hidden??) Worksheets("Data").Visible = True 'select that sheet Worksheets("Data").Activate 'unhide columns A:B of the active sheet (Data) Columns("A:B").Hidden = False 'there's a range that has been named (via Insert|Name|Define) on Sheet 'this picks out the value of that range and stores it into a variable named 'region. 'if you select Sheet, then edit|goto and type in Region 'you'll see the range (a single cell or multiple cells) whose value 'is being put into that variable named Region 'the coder used Region in two spots--once for the range name 'and once for the variable to hold that value. 'it made it easier for him/her, but don't you get confused by it. region = Worksheets("Sheet").Range("Region").Value 'select C3 on the activesheet (still Data) Cells(3, 3).Select 'range(selection, selection.end(xldown)) 'is the same as selecting C3 and then hitting ctrl-shift-downarrow 'if there's data under C3, it'll select C3 to the row above the first 'gap in column C 'try it manually and you'll see. '.count is just returning the number of cells in that range cellcount = Range(Selection, Selection.End(xlDown)).Count 'A bunch of variables are set to 0. Maybe counters??? Maybe subtotals??? 'maybe costs/prices, who knows???? umis = 0 umiu = 0 umip = 0 mcpls = 0 mcplu = 0 mcplp = 0 gvfpls = 0 gvfplu = 0 gvfplp = 0 mshs = 0 mshu = 0 mshp = 0 bdchs = 0 bdchu = 0 bdchp = 0 Co-op 20 wrote: I know almost nothing about visual basic, and my supervisor asked me to add some things into the code of a spreadsheet. I know what the code is supposed to do, but I honestly don't know if I'm doing it right. Can someone tell me what exactly this is doing?? Sub data() Application.ScreenUpdating = False For Each sht In ActiveWorkbook.Sheets sht.Activate ActiveSheet.unprotect Next Worksheets("Sheet").Visible = True Worksheets("Data").Visible = True Worksheets("Data").Activate Columns("A:B").Hidden = False region = Worksheets("Sheet").Range("Region").Value Cells(3, 3).Select cellcount = Range(Selection, Selection.End(xlDown)).Count umis = 0 umiu = 0 umip = 0 mcpls = 0 mcplu = 0 mcplp = 0 gvfpls = 0 gvfplu = 0 gvfplp = 0 mshs = 0 mshu = 0 mshp = 0 bdchs = 0 bdchu = 0 bdchp = 0 These letter groups represent product lines that are being pulled from one sheet and grouped together and placed in another sheet. I have to add another group, but can I just add it into the code because how will excel know what it is referencing too? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
visual basic | Excel Worksheet Functions | |||
Visual Basic and SP2 | Excel Discussion (Misc queries) | |||
changing the visual basic in office 2003 to visual studio net | Excel Discussion (Misc queries) | |||
Visual Basic | Excel Discussion (Misc queries) | |||
Visual Basic Help | Excel Discussion (Misc queries) |