Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

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
0
MarkVrenken
Asked:
MarkVrenken
  • 6
  • 2
1 Solution
 
SteveCommented:
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

0
 
Martin LissRetired ProgrammerCommented:
If CheckBox1.Value = True Then
    ' Do it here
End If

End Sub

Open in new window

0
 
MarkVrenkenAuthor Commented:
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!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Martin LissRetired ProgrammerCommented:
Where and how is "month" defined?
Where and how are "Q1" through "Q4" defined?
0
 
MarkVrenkenAuthor Commented:
And i must add the column is on another sheet than the checkbox!
0
 
MarkVrenkenAuthor Commented:
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
0
 
MarkVrenkenAuthor Commented:
Workbooks(WorkbookName).Sheets("Deals").Columns("B:B").Calculate i have tried this but it doesn't seem to really recalculate it....
0
 
MarkVrenkenAuthor Commented:
hmmm this seems to do the trick.

ThisWorkbook.Worksheets("Deals").EnableCalculation = False
ThisWorkbook.Worksheets("Deals").EnableCalculation = True
ThisWorkbook.Worksheets("Deals").Columns("B:B").Calculate
0
 
MarkVrenkenAuthor Commented:
Sorry for not being clear in the beginning. Luckily i found a solution of my own
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now