Link to home
Start Free TrialLog in
Avatar of MarkVrenken
MarkVrenkenFlag for Netherlands

asked on

Excel VBA update entire column after event

Dear experts,

Is it possible to update an entire column on another through vba? i'm using an activex control checkbox on the sheet. From which the code should fire

thanks in advance,

Mark
Avatar of Steve
Steve
Flag of United Kingdom of Great Britain and Northern Ireland image

If you want to copy one column to another in code then this is simple enough...
But I am guessing that this is not as simple as it sounds...

The following code will copy column 1 of sheet1 to column 1 of sheet2
You can then program alterations in columns or sheet as nescessary.
Thisworkbook.Sheets("Sheet1").columns(1).copy  Thisworkbook.Sheets("Sheet2").columns(1)

Open in new window

If CheckBox1.Value = True Then
    ' Do it here
End If

End Sub

Open in new window

Avatar of MarkVrenken

ASKER

I'm sorry i'm an idiot!
I didn't explain what i want very well. I will try to explain what my thougts are.
I have a sheet with a checkbox. when it is checked i set the value of a cell to 1. When it is unchecked the value is 13. For simplicity sake the cell is A1 of that sheet.
The column that i want to update is based on a function i wrote. Like this. i don't have the code on this computer so forgive me if the code isn't totally correct. see below the code

Function Quartertomonth() 

select case month

case Q1
      Quartertomonth = 1
case Q2
      Quartertomonth = 2
case Q3 
      Quartertomonth = 3
case Q4
      Quartertomonth = 4
case else
       Quartertomonth = Workbooks("workbookExample").sheets("sheet1").Range("A1").Value
end select
end function

Open in new window


so when the checkbox is checked case else =1
and when the checkbox is unchecked case else =  13

So when i check/uncheck the checkbox i want to recalculate the column based on the above function. I hope you guys now can understand:)

thanks for your reply!
Where and how is "month" defined?
Where and how are "Q1" through "Q4" defined?
And i must add the column is on another sheet than the checkbox!
It is defined in a table/column

Month       month numeric(this column is based on the function)
Q1                  1
Q2                  2
                  1 or 13
Q1                  1
Q4                  4
                  1 or 13
Q4                  4
                  1 or 13
Q3                  3


I want this because then i can include or exclude the blanks through the checkbox
Workbooks(WorkbookName).Sheets("Deals").Columns("B:B").Calculate i have tried this but it doesn't seem to really recalculate it....
ASKER CERTIFIED SOLUTION
Avatar of MarkVrenken
MarkVrenken
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for not being clear in the beginning. Luckily i found a solution of my own