English 中文(简体)
采用工作表格,根据投入确定价值
原标题:excel vba loop through worksheets and set values according to input

I m试图对每个工作表格进行校正,并将A栏的100个浏览点与投入参数的价值挂钩。 我希望每张表格都打上一个投入箱,其数值与这一投入相等,但正在出现的情况是,第1号工作表格正在获得最后的投入,并且一栏的所有数值。 a 空白,但表格除外。 1. 导言

Dim wkbkorigin As Workbook
Set wkbkorigin = Workbooks.Open("C:ookB.xls")

For Each ThisWorkSheet In wkbkorigin.Worksheets  
    Subject = InputBox("Enter the  Subject  field for " & ThisWorkSheet.Name & ":")
    For i = 1 To 100  
        Range("A2").Cells(i, 1) = Subject
    Next
Next
问题回答

您不妨修改:

Range("A2").Cells(i, 1) = Subject

:

ThisWorkSheet.Range("A2").Cells(i, 1) = Subject

<代码>Range将自发适用于 Current worksheet(根据您的症状,这是第一份工作表格),因此,你所做的一切只是重复了该工作桌上的囚室。

因此,它们最终达到了最后价值,而其他表格则仍然空白。

此外,不需要休息——简单使用:

ThisWorkSheet.Range("A2:A100").Value = Subject

较快





相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签