Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

My excel macro won't run properly out of project user-form.

$
0
0

Hey guys, 

 So I have this macro I built into a project user-form to organize my excel output from project. The idea is that one button exports the excel file, the second button organizes it to my liking. Here is the code I use to organize the excel file and following the code is my issue.

\

Dim xlapp As Excel.Application
Dim NC As String, tn As String
Dim xlSheet As Worksheet
Dim c As Range

Set xlapp = GetObject(, "Excel.Application")
Set xlSheet = xlapp.ActiveWorkbook.Worksheets(1)
NC = xlSheet.UsedRange.Rows.Count
For Each c In xlSheet.Range("A2:A" & NC).Cells
    Debug.Print c.Value
    If c.Offset(0, 2).Value <> "" Then
        tn = c.Offset(0, 5).Value
    Else
        c.Offset(0, 5) = tn
    End If
Next c
End Sub

What the macro does is read column C for the Work Package number and then copies the task name down until the WP number changes again in column c. Now the issue is if I use any decimals with my WP numbers the macro doesn't rename anything it just skips. Can anyone please help me with this? 

Also on a side note this is the idea behind the macro in brief  ( the slashes represent columns)

The first task WP would be 1 and all the tasks within that WP would have the first task name as the title, once the WP changed to the number 2 or 2.1, the task name would then be whatever task name was in the row for the WP # change.

If this is to overly confusing I will post the excel sheet before and after.


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>