Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro problem - not working properly

Hey guys,

I got 2 sheets in my workbook from one of my web quizzes (both exported from
mysql in
excel format)

sheet Q example:
----------------------------------------------------------------
| A | B |
C |
--------------------------------------------------
| 1 | Who was the first man on the Moon ? | category 1 |
--------------------------------------------------
| 2 | The fastest animal on the planet is.. | category 3 |
---
and so on...
(A column - question no., B col. - question)

sheet A example:
-------------------------------------
| A | B | C |
-------------------------------------
| 1 | John Glenn | 0 |
-------------------------------------
| 1 | Neil Armstrong | 1 |
-------------------------------------
| 1 | Yuri Gagarin | 0 |
-------------------------------------
| 2 | Turtle | 0 |
-------------------------------------
| 2 | Cheetah | 1 |
----
and so on...
(A column- question no. answers refer to, B- answers, C- 0 is false answer,
1 is true)

I got 2 macros which should work in order to do the following:

| A | B | C |
----------------------------------------------------
question no. | question | | <- font
is bold
----------------------------------------------------
| | answer 1 | true/false|
----------------------------------------------------
| | answer 2 | true/false|
----------------------------------------------------
| | answer 3 | true/false|

<line break here

----------------------------------------------------
question no. | question | | <- font
is bold
----------------------------------------------------
| | answer 1 | true/false|
----------------------------------------------------
| | answer 2 | true/false|
----------------------------------------------------
| | answer 3 | true/false|
.....

Macros that I use:

1) Sorting Q&A to QA sheet, questions font in bold

Sub macro1()
'
' gsnuxx
' rev 1
'
k = 1
Set q = Sheets("q")
Set a = Sheets("a")
Set qa = Sheets("qa")
nq = q.Cells(Rows.Count, "A").End(xlUp).Row
na = a.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To nq
n = q.Cells(i, 1).Value
qa.Cells(k, 1).Value = n
qa.Cells(k, 2).Value = q.Cells(i, 2).Value
qa.Cells(k, 2).Font.Bold = True

k = k + 1
For j = 1 To na
m = a.Cells(j, 1).Value
If m = n Then
qa.Cells(k, 2).Value = a.Cells(j, 2).Value
If a.Cells(j, 3).Value = 0 Then
qa.Cells(k, 3).Value = " "
Else
qa.Cells(k, 3).Value = "+"
End If
k = k + 1
End If
Next
Next
End Sub

2) Putting a), b), c), d) in front of the answers and blank row indent.

Public Sub ProcessData()
Const TEST_COLUMN As String = "B"
Dim i As Long
Dim LastRow As Long
Dim letter As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

If .Cells(i, TEST_COLUMN).Offset(0, -1).Value < "" Then

letter = 97
Else

.Cells(i, TEST_COLUMN).Value = Chr(letter) & ") " &
..Cells(i, TEST_COLUMN).Value
letter = letter + 1
End If
Next i
For i = LastRow - 1 To 1 Step -1

If .Cells(i + 1, TEST_COLUMN).Offset(0, -1).Value < "" Then

.Rows(i + 1).Resize(1).Insert
End If
Next i
End With

End Sub

The problem is that the macros aren't working as they should - the questions
are not bolded properly (the rows are bolded randomly as it seems to me),
the blank row indent is not rightly positioned (sometimes it occures in the
middle of the answers, instead in the end dividing the question with answers
with the following question. I'd like to merge those 2 macros into one which
would do all the work.

I hope someone can help me with this one ?

Thanks in advance !

Marko

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro not working properly when run automatically ATChurch Excel Discussion (Misc queries) 9 April 1st 10 03:01 PM
Macro is not working properly Sherees Excel Discussion (Misc queries) 5 December 26th 09 09:18 AM
Macro not working properly on change in cell value Monk[_2_] Excel Programming 2 February 7th 09 09:48 AM
Macro not working properly when the file is shared Chakri Excel Worksheet Functions 0 August 30th 06 01:33 PM
Macro Not Working Properly PA Excel Programming 4 February 8th 06 03:34 AM


All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"