worksheet

How can I create new spreadsheet worksheets in Ruby using the Spreadsheet gem?

独自空忆成欢 提交于 2019-12-20 04:26:19
问题 Specifically what I am trying to do is add new worksheets alongside ones already there. I've tried to use book.create_worksheet :name => 'new_sheet' but it overwrites the previous worksheet. I searched the site here and saw some people using a different gem that allowed "book.add_worksheet" (the Spreadsheet gem is supposed to have support for other gems, like it's supposed to be like 3 gems in 1 or something...) and that almost worked as well but I get the error undefined method 'workbook='

Can't enter break mode at this time

人盡茶涼 提交于 2019-12-19 10:28:33
问题 This has been happening increasingly, when I have a sheets.add or sheets.delete in excel VBA. After searching and searching I finally found the official Microsoft support page on it. My question is, does anyone know why I could have stepped through this code just fine over and over, and then all of a sudden it starts doing what Microsoft says it would always do, and is there a way to fix it? Sub foo() Sheets.add debug.print "sheet added" 'breakpoint here End sub It's as simple as that. You

Changing sheet codename Run-Time Error 9: Subscript out of range

强颜欢笑 提交于 2019-12-19 05:45:12
问题 I've code which, when I press a button, will add a new sheet to a workbook and change the codename of the sheet to make it easier to refer to later in my code. Dim wbk As Workbook Dim wks As Worksheet Set wbk = ThisWorkbook wbk.Sheets.Add.Name = "Admin - Save Log" Set wks = wbk.Worksheets("Admin - Save Log") wks.Parent.VBProject.VBComponents(wks.CodeName).Name = "wksAdminSaveLog" This does work - HOWEVER - only when I have the "Developer" window open or have previously had it open. If I click

How to execute a function for each cell in a column and loop through all workbooks?

隐身守侯 提交于 2019-12-18 21:18:25
问题 Here's what I have so far: Sub TrimColumnD() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets Dim c As Range For Each c In ActiveSheet.UsedRange.Columns("D").Cells c.Value = WorksheetFunction.Trim(c.Value) Next c Next ws End Sub The trim function only works on the cells in the first worksheet. 回答1: Please change this line: For Each c In ActiveSheet.UsedRange.Columns("D").Cells into this one: For Each c In ws.UsedRange.Columns("D").Cells In your code internal loop refers to

Copy sheet and get resulting sheet object?

梦想的初衷 提交于 2019-12-17 07:30:24
问题 Is there any easy/short way to get the worksheet object of the new sheet you get when you copy a worksheet? ActiveWorkbook.Sheets("Sheet1").Copy after:=someSheet It turns out that the .Copy method returns a Boolean instead of a worksheet object. Otherwise, I could have done: set newSheet = ActiveWorkbook.Sheets("Sheet1").Copy after:=someSheet So, I wrote some 25 lines of code to get the object. List all sheets before the copy, list all sheets after, and figure out which one is in the second

Show all tabs with worksheet names (use multiple rows, or alternative, if needed)

限于喜欢 提交于 2019-12-13 22:14:33
问题 I have a workbook with many worksheets. I would like to see the tabs for all available worksheets at once, which will need more than one row of tabs at the bottom. From what I searched, this is not possible. The closest I got is right clicking on the arrows for navigating the sheets (at the bottom left), and then "More Sheets..." Is there anything that gives more visibility at once? 回答1: You can create a Table of Contents worksheet. Each cell in this sheet would display a tab name and contain

How do I pass worksheet and ranges as variables?

主宰稳场 提交于 2019-12-13 16:01:16
问题 I want to pass the names of sheets and ranges between subroutines. The following throws a "Subscript out of range" error: Sub This() x = "Sheet1" y = "D3" MsgBox (x.Range(y).Value) End Sub This is a sample of my Project Explorer. 回答1: Your worksheet's .Name property is Valuation ; its Worksheet .CodeName property is Sheet1 . dim x as string, y as string dim xx as worksheet, yy as range x = "Valuation" set xx = worksheets(x) y = "D3" set yy = xx.range(y) debug.print yy.address(0,0, external:

I'm trying to add a count to the number of searches found in my code

我的梦境 提交于 2019-12-13 11:25:27
问题 My code follows: Dim ws As Worksheet Dim ExitLoop As Boolean Dim SearchString As String, FoundAt As String Set ws = Worksheets("detail_report") On Error GoTo Err Set oRange = ws.Cells SearchString = "front input" Set aCell = oRange.Find(What:=SearchString, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If Not aCell Is Nothing Then Set bCell = aCell FoundAt = aCell.Address Do While ExitLoop = False Set aCell = oRange

Copy an Entire Worksheet - Keep Same Formatting

烂漫一生 提交于 2019-12-13 02:21:06
问题 I would like to copy worksheet "Trial Sheet" located in workbook "Trial Data.xlsx" to a seaparate workbook called "Copy Worksheet". I would like to keep the format (column width, zoom, etc.), be able to copy the worksheet without having to open the "Trial Data" workbook which the macro doesn't seem to do. The macro I recorded is as follows. Sub worksheet_copy() Windows("Trial Data.xlsx").Activate Cells.Select Selection.Copy Windows("Copy Worksheet.xlsm").Activate Cells.Select ActiveSheet

Copying data from one (closed) workbook into another (already open) workbook

心已入冬 提交于 2019-12-13 00:57:14
问题 I've managed to semi-successfully create a macro that copies the contents of a couple of columns in one (closed) workbook to another, already opened workbook. Problem is that the code below results in the last row always showing N/A for each column... Do you know what the mistake in my code is? I would prefer to fix it than adding another line of code that removes the N/As. Here's the code (also I noticed that using ActiveWorkbook or ThisWorkbook slows the macro down considerably... turned