Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50068

syntax error. Can this be done or is there a better way?

$
0
0
hello all,

Im trying to write a big macro but im having issues with a line in one of the subs. I set "bok" and "pag" as variables so I can have the contents display in a cell (with other stuff) Ive tried several ways of changing the syntax of the variabls but it keeps giving me an error. Does anyone know how I need to write the variables to display the cell's contents? or is there a better way of achieving what im trying to do?


Code:

Sub cmt()
 Dim cmt As Long
Dim I As Long
Dim bok As Range
Dim pag As Range
Dim x As Long

x = 0


cmt = 2
  I = 0

Set bok = Worksheets("runsheet").Cells(3, 2)
Set pag = Worksheets("runsheet").Cells(4, 2)


 While ThisWorkbook.Sheets("runsheet").Cells(cmt, 10) <> ""

    Range("Origin" & I).Select
    Selection.Offset(4, 0).Select
   
    ActiveCell = Range("origin" & I) & " # " & Range("symptom" & x) & " Bk " & bok & "-Pg " & pag & ") " & ThisWorkbook.Sheets("runsheet").Range(cmt, 10)
  ActiveCell.Font.ColorIndex = 46
 
Set bok = bok.Offset(1)
Set pag = pag.Offset(1)

 
  cmt = cmt + 1
  I = I + 1
  x = x + 1
 
    Wend
End Sub


Viewing all articles
Browse latest Browse all 50068

Trending Articles