我有一些代码,我试图根据另一个(主要)工作簿中单元格的内容对csv文件中的数据集进行排序。然后根据这种排序,在第一列和第六列之间复制可见单元格的范围,但是在最后一行具有动态行,因此该范围将是动态的。然后将这个动态范围粘贴到主表中,这将允许我对该数据集做进一步的工作。
似乎无法使排序工作或动态范围工作。我已经尝试了以下代码的各种变体,并正在寻找灵感。
Sub Get_OA_Data()
'Find OA data from source SQL file and copy into serial number generator
Dim ws As Worksheet
Dim wkb2 As Workbook
Dim ws2 As Worksheet
Dim rng As Range
Dim rng2 As Range
Dim LastRow As Long
Dim LastColumn As Long
Dim StartCell As Range
'This section sets the workbooks and worksheets to be used for this macro
Set ws = ThisWorkbook.Worksheets("Data Entry")
Set wkb2 = Workbooks.Open("\\srvabdotfpr08\PC_APPS\forum\Gateshead Serialisation\sys_serialisation1.csv")
Set ws2 = wkb2.Worksheets("sys_serialisation1")
Set rng2 = ws.Range("F6")
' This line deletes any content of the cannot assign serial number added previously
ws.Range("I6:I7").ClearContents
'This hides all rows which do not match the desired OA number (found in rng2)
For Each Cell In ws2.Range("A1").End(xlDown)
If Left(Cell.Value, 6) <> rng2.Value Then
Cell.EntireRow.Hidden = True
End If
Next Cell
Set StartCell = ws2.Range("A1")
LastRow = StartCell.SpecialCells(xlCellTypeVisible).Row
LastColumn = StartCell.SpecialCells(xlCellTypeVisible).Column
'This section selects and copies the visible range from csv file into serialisation generator
Set rng = ws2.Range(StartCell.ws2.Cells(LastRow, LastColumn))
rng.Copy
ws.Activate
ws.Range("D12").Select
Selection.PasteSpecial 'Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
任何帮助将不胜感激,我已经买了几本书,但是我的书中没有任何东西可以解决这个问题。
P.S我使用了非常相似的代码,并具有特定的设置范围,并且效果很好,但是这一点让我很困惑。数据集可能还存在一个问题,这就是为什么我在代码中有LEFT公式的原因(但这似乎可以正常工作)。
答案 0 :(得分:1)
尝试...
import React, { useState, useEffect } from 'react'
import styled from 'styled-components'
export function Modal({ show, children }) {
return (
<DivModal show={show}>
{children}
</DivModal>
)
}
const DivModal = styled.div`
display: ${props => (props.show ? 'block' : 'none')};
`