English 中文(简体)
从“P”中自动输入“E”的这么多栏
原标题:Automatically inputting "E" so many columns over from "P"
  • 时间:2023-09-07 02:16:02
  •  标签:
  • excel
  • vba

I am making a growing calendar, where each variety has a different growing length. I would like to create a VBA? which will automatically input "E" (Expected Harvest) into the cell so many columns to the right depending on the variety from "P" (Planted) The "P" would be manually inputted. And "H" would be manually inputted when the plant has been Harvested.

Once it has been Harvested, I would like that row to go to the bottom. So all the expected plants to be harvested, are at the top.

What it would look like ideally What it would look like ideally

“Sheet

我知道最终结果,在那里,需要帮助

问题回答

用户在第一份表格的模块中书写该代码,然后输入改动活动,以插入<代码>。 E 。

Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .CountLarge = 1 Then
            If .Row > 2 And .Column > 5 And UCase(.Value) = "P" Then
                  Update sheet name as need, loading the 2nd table
                arr = Sheets("Sheet2").[a1].CurrentRegion.Value
                For i = 2 To UBound(arr)
                    If arr(i, 4) = Me.Cells(.Row, 2) Then
                        If .Column + arr(i, 5) <= Me.Columns.Count Then
                            Application.EnableEvents = False
                            .Offset(0, arr(i, 5)).Value = "E"
                            .Offset(0, arr(i, 5)).Interior.Color = 12574926
                            Application.EnableEvents = True
                        End If
                    End If
                Next
            End If
        End If
    End With
End Sub

b 以前,在欧佩斯最后一行的<代码>E的位置似乎不正确。 <代码>CO和GO>的日数相同。

“entergraph





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

热门标签