I'm trying to work a little macro that will format some data so that I can make a price sheet. When I put the information in excel, it works fine, but some of the notes make it onto the next line. This is supposed to take the cell contents and append the cell above it with them.
Sub Macro1() For i = 8 To 100000 If Left(ActiveSheet.Cells(i + 1, 1).Value, 2) = "AC" Or ActiveSheet.Cells(i + 1, 1).Value = vbNullString Then Else If Left(ActiveSheet.Cells(i + 1, 1).Value, 4) = "Page" Then ActiveSheet.Rows(i + 1).Delete shift:=xlUp Else Dim tempString As Variant tempString = ActiveSheet.Cells(i + 1, 1).Value ActiveSheet.Cells(i, 1).Value = ActiveSheet.Cells(i, 1).Value + " " + tempString ActiveSheet.Rows(i + 1).Delete shift:=xlUp i = i - 1 End If End If Next End Sub
It works just fine until I run into a cell value:
(This isn't really a formula, it just looks like one) which gives me a type mismatch error. Should I be using another way to specify cell contents? Also, there's probably a better way to specify the range, I really just want to go all the way down column A. Any help appreciated.
preguntado el 09 de marzo de 12 a las 23:03
Sólo tiene que utilizar
.Formula en lugar de
This will return a string for a constant where it is a constant, or a string for the "formula" that excel thinks that it is, as appropriate.