kate.middleton
New Member
- Joined
- Mar 24, 2012
- Messages
- 31
Hello Everybody,
I have a Data in Column A something like This,
567
567
567
789
654
321
In this case it opens the word document write 567, 3 times then close it. Then again open the same word doc write 789, 1 time then close and so on. I am fail to make the logic in if Else Statement. Your help will be appreciated.
I have a Data in Column A something like This,
567
567
567
789
654
321
In this case it opens the word document write 567, 3 times then close it. Then again open the same word doc write 789, 1 time then close and so on. I am fail to make the logic in if Else Statement. Your help will be appreciated.
Code:
Sub Test()
Dim Counter_Start As Integer
Counter_Start = 2
Dim Counter_End As Integer
Counter_End = ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Row
Dim Number_Array() As String
ReDim Number_Array(2 To Counter_End)
For iCounter = Counter_Start To Counter_End
Number_Array(iCounter) = ThisWorkbook.Sheets(1).Range("A" & iCounter).Value
Next iCounter
Number_Array_Preserve = Number_Array
str_Word = "H:\MAKROS\Test.docx"
Set obj_Word = GetObject(str_Word)
Set rngWord = obj_Word.Content
'''''From Here i am unable to make logic, I want that when the value gets change in column A then it write the values somewhere in word document.
For iCounter = Counter_Start To Counter_End
If Number_Array(iCounter) = Number_Array(iCounter + 1) Then
ElseIf Number_Array(iCounter) <> Number_Array(iCounter + 1) Then
iCounter = iCounter + 1
End If
Next iCounter
End Sub