[英]Part of the range formatted as text
Following the answer by @Pᴇʜ in this link Merging two macros 在此链接中按照@Pᴇʜ的答案进行操作合并两个宏
I have an additional challenge. 我还有一个挑战。 Within the Named Range called "RawTab1" the column J contains values "Year" formatted as '2018 and in the column K contains values "Months" formatted as '12 在名为“ RawTab1”的命名范围内,列J包含格式为'2018的 “年份”值,在列K中包含格式为'12的值“月份” . 。
I use the macro by @Pᴇʜ to copy the rng "RawTab1" to the Table called "DataTable" in the sheet called "Data" 我通过@Pᴇʜ使用宏将rng“ RawTab1”复制到工作表“ Data”中的表“ DataTable”
So my question is: 所以我的问题是:
Otherwise the macro is working perfect. 否则,宏将完美工作。
Try: 尝试:
Public Sub Combined()
Dim sht As Worksheet
Set sht = ThisWorkbook.Worksheets("Data")
sht.Range("A3:M3", sht.Range("A3:M3").End(xlDown)).ClearContents
With Worksheets("Raw Data").Range("RawTab1")
'copy everything from RawTab1 but not the first 2 rows
Dim Crng As Range
Set Crng = .Resize(RowSize:=.Rows.Count - 2).Offset(RowOffset:=2)
End With
sht.Range("A2").Resize(Crng.Rows.Count, Crng.Columns.Count).Value = _
sht.Evaluate("IF(ISNUMBER(--" & Crng.Address(0, 0, xlA1, 1) & "),--" & Crng.Address(0, 0, xlA1, 1) & "," & Crng.Address(0, 0, xlA1, 1) & ")")
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.