macro help!!!

lucki_87

New Member
Joined
Feb 19, 2011
Messages
27
Const ColGroup = 4
Const ColLevel = 4
Const ColAdvisor = 6
Const ColInitial = 7
Option Explicit

Private Sub BtnAdd_Click()
Dim NbRangeLog As Integer
Dim i As Integer

Dim wsLog As Object


With wsLog
NbRangeLog = .Columns(1).End(xlDown).Row

For i = 1 To NbRangeLog

.Cells(i, ColAdvisor).Value = ReturnAdvisor(.Cells(i, ColGroup).Value, .Cells(i, ColLevel).Value)
.Cells(i, ColInitial).Value = ReturnInitial(.Cells(i, ColAdvisor).Value)
Next i
End With
End Sub

Private Sub BtnReset_Click()
wsLog.Columns(ColAdvisor).Clear
wsLog.Cells(1, ColAdvisor).Value = "Advisors"

wsLog.Columns(ColInitial).Clear
wsLog.Cells(1, ColInitial).Value = "Initials"
End Sub

Option Explicit
Public Function ReturnAdvisor(Group As String, Level As String) As String
Dim MyRow As Range

ReturnAdvisor = ""

For Each MyRow In Range("list_Advisor").Rows
If Left(MyRow.Cells(1).Value, 2) = Group And Right(MyRow.Cells(1).Value, 2) = Level Then
ReturnAdvisor = MyRow.Cells(1).Value
End If
Next MyRow
End Function
Public Function ReturnInitial(Name As String) As String
ReturnInitial = FindInitialAdvisor(Name, wsLis.Cells(1, 1))
End Function

Public Function FindInitialAdvisor(Name As String, Cell_list As Range) As Integer
Select Case Cell_list.Value
Case Name
FindInitialAdvisor = Cell_list.Offset(columnoffset:=1, rowoffset:=1).Value
Case ""
FindInitialAdvisor = ""
Case Else
FindInitialAdvisor = FindInitialAdvisor(Name, Cell_list.Offset(rowoffset:=1, columnoffset:=0))
End Select
End Function

my code isnt compling
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You haven't set wslog to anything. If ws log is a worksheet (say, Sheet1 for example), try:
Code:
Dim wslog as Worksheet
Set wslog = Sheets("Sheet1")
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,882
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top