English 中文(简体)
VBA Excel cell。 价值不显示任何价值
原标题:VBA Excel cell.value does not show any value
  • 时间:2023-12-21 11:03:34
  •  标签:
  • excel
  • vba

我愿为节省这些档案留出余地。

Loop Excel Save As

然而,我不理解为什么<代码>Cell.Value没有回落,而Cell.Address/code>。 工作

我的法典如下:

 Sub Creator()

     Dim ObjWorkbook As Workbook
     Set ObjWorkbook = Workbooks.Open( _
 "C:myCosts.xlsx")

     Dim cRng As Range, c As Range, Row As Range, cell As Range
     Dim strName As String, pName As String

     strName = "-Jan24-Timesheet"

     Dim i As Long

     Set cRng = Sheet1.Range("AA1:AA5")


     For Each Row In cRng.Rows
         For Each cell In Row.Cells
             Debug.Print cell.Value & strName
         Next cell
     Next Row

Debug。 印刷仅像以下通用插图

“enter像

我怎么能够把细胞价值带在我的住所?

在我进一步开会之前,我使用了<代码>Debug.Print的功能。 在我开始提出这些文件之前,我需要在现阶段找到一个很好的解决办法。

问题回答

如果我错了,请更正我,但我想你会再做些什么:你再用一本宏观工作手册,在“C:myCosts.xlsx”上开另一份工作书,该书的数值可用于更多的工作手册,你希望从你所提到的链接()中节省下来,现在你只是从其他工作手册(Costsxs)中收回价值。

如果情况如此,你可以采取两种做法:

  1. Here s your updated code that works on my system using the answer to the question you linked (Loop Excel Save As) and the comments to your own question above:

这是我从以下代码获得的产出的print。

Sub test1()
    Dim wb2 As Workbook
    Dim wb2ws1 As Worksheet
    Dim cRng As Range, c As Range, Row As Range, cell As Range
    Dim strName As String, pName As String

    strName = "-Jan24-Timesheet"
    
    Set wb2 = Workbooks.Open("C:myCosts.xlsx")
    Set wb2ws1 = wb2.Sheets("Sheet1")
    Set cRng = wb2ws1.Range("AA1:AA5")
    Debug.Print "Opened workbook: " & wb2.Name & ", sheet: " & wb2ws1.Name
    
    For Each cell In cRng.Cells
        Debug.Print cell.Value & strName
    Next

    wb2.Close SaveChanges:=False: Set wb2 = Nothing
结尾处
  1. 这里还有你更新的代码,但如上面的公开方法,在回收价值时,成本-xsx将t闪光放在屏幕上:

    Sub test2() Dim exlapp As New Excel.Application Dim wb2 As Excel.Workbook Dim wb2ws1 As Worksheet Dim cRng As Range, c As Range, Row As Range, cell As Range Dim strName As String, pName As String

     strName = "-Jan24-Timesheet"
    
     Set wb2 = exlapp.Workbooks.Add("C:myCosts.xlsx")
     Set wb2ws1 = wb2.Sheets("Sheet1")
     Debug.Print "Inside workbook: " & wb2.Name & ", sheet: " & wb2ws1.Name
     Set cRng = wb2ws1.Range("AA1:AA5")
    
     For Each cell In cRng.Cells
         Debug.Print cell.Value & strName
     Next
    
     wb2.Close SaveChanges:=False: Set wb2 = Nothing
     exlapp.Quit: Set exlapp = Nothing
    

    结尾处





相关问题
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 ...

热门标签